Results 1 to 6 of 6

Thread: VBA excel grab macro

  1. #1

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    5

    VBA excel grab macro

    Hey guys,

    Im having a little trouble writing a VBA excel macro that, when a button is pressed, copies data from one (open) excel data file to a different (open) master file that will aggregate the data. The data files will we opened separately and the button will be pressed each time.

    The information in each data file needs to be copied from row 3, column A until end of data, and the pasted AT THE END OF ANY DATA in the master file starting at column.

    For each of the data files' data; In column A I need the date created from the properties information. In column B I need the time created (to the minute) from the properties information. In column C I need the data in cell E2 of the data file to also be copied next to that files data.

    There are around 50 data files I need to copy into the master file.

    If anyone can do this I would really appreciate your help.

  2. #2
    Hyperactive Member eranfox's Avatar
    Join Date
    May 2001
    Posts
    492

    Re: VBA excel grab macro

    Quote Originally Posted by njohnston
    ...

    The information in each data file needs to be copied from row 3, column A until end of data, and the pasted AT THE END OF ANY DATA in the master file starting at column.

    For each of the data files' data; In column A I need the date created from the properties information. In column B I need the time created (to the minute) from the properties information. In column C I need the data in cell E2 of the data file to also be copied next to that files data.

    ...
    Hello njohnston,
    Welcome to the VBForums.com
    for a start, where is the button placed? in the master excel file or in any other file?
    do you know how to record a macro? ths can be very helpfull for you when you'll build your own macro.
    do you have one workbook or 50 as you mentioned?

    VB Code:
    1. Range("A3").Select
    2.     Range(Selection, Selection.End(xlDown)).Select
    3.     Selection.Copy
    4.     Range("D3").Select
    5.     ActiveSheet.Paste

    this simple macro copies all the data from row 3 col A to col D starting from row 3 in the same Sheet...

    Is that you need for a start?

    Best Regards,
    ERAN
    Eran Fox
    ASSEMBLER,C,C++,VB6,SQL...

  3. #3

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    5

    Re: VBA excel grab macro

    Eran,

    Thats a great start. I am only new to VBA, so I don't know much about programming. The button will be in the master file. So each time I need data I will open up the data file, press the macro button in the master file, and the data will be copied into the master file.

    Thanks.

  4. #4

    Thread Starter
    New Member
    Join Date
    Dec 2005
    Posts
    5

    Re: VBA excel grab macro

    I have 50 data files (workbooks), but each one needs to be added separately.

  5. #5
    Hyperactive Member eranfox's Avatar
    Join Date
    May 2001
    Posts
    492

    Re: VBA excel grab macro

    Hello again,
    do you understand that you will have to run on all the 50 workbooks every time and to open them through the code means you cant change their names!
    this will take a long time.
    i'm sure the code for that is simple and if it wasnt 4:00 in the morning i would have come with some example... ( i will try to write something tommorow)

    but for now few tips to start with:
    VB Code:
    1. Range("A3").Select
    2.     Selection.End(xlDown).Select
    this will bring you to the next (last) cell in the "A" column with values in it
    but if you have cells with no values between cells with values then the focus will be on the first cell with values in it.

    VB Code:
    1. Range("A3").Select
    2.     Range(Selection, Selection.End(xlDown)).Select
    this will select all the cells in the range between the A3 cell and last cell as i explained above.

    VB Code:
    1. Shell("C:\Program Files\Microsoft Office\OFFICE11\EXCEL.EXE
    2. C:\My Dcouments\secondWorkbook.xls", vbNormalFocus)
    this will open a new work group, change the path and file name for your code.

    Good night i need some sleep...
    Best Regards,
    ERAN
    Eran Fox
    ASSEMBLER,C,C++,VB6,SQL...

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: VBA excel grab macro

    Moved to Office Development.

Posting Permissions

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



Click Here to Expand Forum to Full Width