+ Reply to Thread
Results 1 to 16 of 16

VB Code to copy certain data based on header

  1. #1
    Forum Contributor
    Join Date
    01-31-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010
    Posts
    193

    VB Code to copy certain data based on header

    Hello:

    Please refer to attached file.
    Sheet "Temp" has credit card transcation.
    In Sheet "Sheet1", i have header as Date,Reference,Description,Card Member,Amount

    I need VB Code to copy all transaction from "Temp" sheet to "Sheet1" for defined Header.
    Sometime, Cardmember Data may not be there in "Temp" sheet.
    In this case I will need to enter as "Joe Doe"
    I have manually copied the data in "Sheet1"

    Let me know if you have any questions.
    Thanks.

    R
    Attached Files Attached Files

  2. #2
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: VB Code to copy certain data based on header

    Hi rmomin,

    Try below code ...
    Please Login or Register  to view this content.
    Last edited by nankw83; 05-10-2021 at 03:12 PM. Reason: Added line for blank Card Member
    If I was able to help, you can thank me by clicking the * Add Reputation under my user name

  3. #3
    Forum Contributor
    Join Date
    01-31-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010
    Posts
    193

    Re: VB Code to copy certain data based on header

    Hello nankw83:

    Thanks a lot, works

    R

  4. #4
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: VB Code to copy certain data based on header

    Glad to help

    You can thank those who have helped by clicking the star icon under their usernames to * Add Reputation

  5. #5
    Forum Contributor
    Join Date
    01-31-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010
    Posts
    193

    Re: VB Code to copy certain data based on header

    Hello:

    Please refer attached...
    Its not doing as it suppose to.
    I deleted Card Member column and tried the code.
    But its not copying and pasting to the correct column.
    Please check and let me know.
    Thanks

    R
    Attached Files Attached Files

  6. #6
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: VB Code to copy certain data based on header

    I have already shutdown my PC heading to bed & I can’t open .xlsb files from my mobile. However, if you changed the order of the columns, you need to adjust the same from my previous code - the below part of code is referring the columns needed

    Array(1, 13, 3, 4, 6)

  7. #7
    Forum Contributor
    Join Date
    01-31-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010
    Posts
    193

    Re: VB Code to copy certain data based on header

    Hello:

    I think instead of Column #, Code need to look for Header Date, reference, Description, Card Member and Amount.

    R

  8. #8
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,518

    Re: VB Code to copy certain data based on header

    Please Login or Register  to view this content.

  9. #9
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: VB Code to copy certain data based on header

    jindon's code is the way to go ... I have just added few lines to loose the formatting of the original sheet

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    01-31-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010
    Posts
    193

    Re: VB Code to copy certain data based on header

    Hello:
    Please refer to attached file..
    Both of the above code is erroring out @

    Please Login or Register  to view this content.
    Would appreciate if you can put the code in the file and try..and send the working file.

    Thanks

    R
    Attached Files Attached Files

  11. #11
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: VB Code to copy certain data based on header

    The error you're getting is due to that you removed the column with header 'Card Member' from sheet Temp. Sheet Temp looks like a statement provided by a bank/credit card company so does it keep changing ? The format & columns order ?

  12. #12
    Forum Contributor
    Join Date
    01-31-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010
    Posts
    193

    Re: VB Code to copy certain data based on header

    Hello:

    Yes Header will keep changing.
    Some cards statement would not have certain header.
    That is the reason, i named Header in Sheet1.
    ONly those header data needs to be copied.
    If Card member column is not in Temp sheet then as mentioned add "Joe Doe".

    Also, the data header in the Temp sheet is not likely to be fixed at certain column #.
    That is why, i had said to look for Header in Temp sheet and copy that data in Sheet1 for that particlar column.

    I hope this is clear explanation.
    Please let me know if you have any questions.
    Thanks.

    R

  13. #13
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: VB Code to copy certain data based on header

    Ok, this is another option looping through your 5 columns in Sheet1 & assuming header will be found in row #7 in sheet Temp
    Please Login or Register  to view this content.

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,518

    Re: VB Code to copy certain data based on header

    Please Login or Register  to view this content.

  15. #15
    Forum Contributor
    Join Date
    01-31-2012
    Location
    Georgia
    MS-Off Ver
    Excel 2010
    Posts
    193

    Re: VB Code to copy certain data based on header

    Hello nankw83:

    Yes it works now...
    I like to add Star Reputation but its not allowing me.

    But , Thanks a lot..

    R

  16. #16
    Forum Expert nankw83's Avatar
    Join Date
    08-31-2015
    Location
    Kuwait
    MS-Off Ver
    365
    Posts
    1,712

    Re: VB Code to copy certain data based on header

    Quote Originally Posted by rmomin View Post
    Hello nankw83: Yes it works now...
    I like to add Star Reputation but its not allowing me. But , Thanks a lot..
    Noted, glad to help

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Copy Data Between Sheet based on The Same Name Header
    By Jhon Mustofa in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-03-2020, 10:49 PM
  2. Need a Formula to copy data to different cells based on a column header
    By jpiquette in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-20-2019, 12:22 PM
  3. Copy data based on column header in a table to a new location
    By karthik.jaish in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-20-2016, 03:05 AM
  4. [SOLVED] Copy columns based on header (Without header)
    By Michael_BU in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 10-15-2014, 08:07 AM
  5. [SOLVED] Based on Column Header find and copy data from one sheet to another
    By Sachy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-31-2014, 10:00 AM
  6. [SOLVED] Copy column data from multiple worksheets to single worksheet based on header criteria
    By nateaskins in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 03-21-2014, 10:42 AM
  7. Macro code to pull data from different sheets based on the header of the main sheet
    By Shanthuday in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 08-21-2012, 05:00 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1