+ Reply to Thread
Results 1 to 14 of 14

Need code to copy and paste based on variable rows

  1. #1
    Registered User
    Join Date
    04-30-2013
    Location
    NJ
    MS-Off Ver
    Excel 2007
    Posts
    4

    Smile Need code to copy and paste based on variable rows

    Hello
    I am writing a macro to combine a few different different spreadsheet.
    Out team individiually type out a list of dailt deliverables.
    Every morning, someone manually goes in an grabs all the rows in everyone's files and combines then in a master file.
    The amount of rows changes day to day based on work load.
    But I am not sure the code to use to select only the rows that have data in them.
    Can anyone help with that code??
    Thanks
    Bonnie

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: Need code to copy and paste based on variable rows

    Please attach a sample Workbook so that we can understand the data you are talking about!
    Cheers!
    Deep Dave

  3. #3
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Need code to copy and paste based on variable rows

    Hi, Bonnie ,

    maybe like this:
    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  4. #4
    Registered User
    Join Date
    04-30-2013
    Location
    NJ
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Need code to copy and paste based on variable rows


  5. #5
    Registered User
    Join Date
    04-30-2013
    Location
    NJ
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Need code to copy and paste based on variable rows

    I need something that will go out and open each one and copy and past into master under the last one, so the cells will always ver variable.
    Thanks!

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Need code to copy and paste based on variable rows

    Hi,

    Quote Originally Posted by msexcelathome
    so that we can understand
    We?

    @bonnie6850:
    maybe RDBMerge, Excel Merge Add-in for Excel for Windows may help.

    Ciao,
    Holger

  7. #7
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,873

    Re: Need code to copy and paste based on variable rows

    "We" goes to anyone who might want to respond..

  8. #8
    Registered User
    Join Date
    04-30-2013
    Location
    NJ
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Need code to copy and paste based on variable rows

    Hi Holger, this is my code, can you let me know where I should put the above code in?
    Also, do you know what code I would use to add a subject into the email listed in the code??
    Thank you so much!!

    Please Login or Register  to view this content.

  9. #9
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Need code to copy and paste based on variable rows

    Hi, bonnie6850,

    this is hard-coded for the files to open, will all the files be in one folder or shouldn´t be anything within the code to only open the workbnooks for a special day?

    Code is untested as I´m running out of time for a test:
    Please Login or Register  to view this content.
    Ciao,
    Holger

  10. #10
    Registered User
    Join Date
    06-16-2010
    Location
    Dayton, NJ
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Need code to copy and paste based on variable rows

    Hi Holger
    This worked perfectly!!
    The files are in all different folders, I think I am going to make everyone use a standard file name, only their name on their current file, so I don't have the build the dates into the file names, it would be a pain with people not updating and weekends. My last question for you is I need to copy over the the Values and Number formats, the master does not have the coloring we use for the file. Please let me know what I can do you copy that over.
    Thanks soooo much!!!

    Bonnie

  11. #11
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Need code to copy and paste based on variable rows

    Hi, Bonnie,

    the following lines may help (they are for one sheet but I´m sure you may adapt them as needed):
    Please Login or Register  to view this content.
    Although I wouldn´t use Rows here but only color the range as needed.

    Ciao,
    Holger

  12. #12
    Registered User
    Join Date
    06-16-2010
    Location
    Dayton, NJ
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Need code to copy and paste based on variable rows

    Hi Holger
    Not sure that will work, I am using your code to copy and paste the different ranges:
    How to I add it into this code?
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    06-16-2010
    Location
    Dayton, NJ
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Need code to copy and paste based on variable rows

    Here is the source file and the master.
    How would I go about setting in the formatting since the rows change daily in all the different lists?
    Thanks
    Bonnie
    Attached Files Attached Files

  14. #14
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Need code to copy and paste based on variable rows

    Hi, Bonnie,

    for this combination it may look like this (although I´m still not happy with copying whole rows instead of the used range only)
    Please Login or Register  to view this content.
    The indivual workbooks are counted by variable lngLast while lngFree get the first free row in the master workbook.

    Ciao,
    Holger

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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