+ Reply to Thread
Results 1 to 5 of 5

Thread: copy/paste macro...

  1. #1
    Registered User
    Join Date
    11-06-2008
    Location
    Illinois
    Posts
    63

    copy/paste macro...

    I have a total of 30 sheets in my workbook. I would like to copy rows 21:1000 from sheets 5 - 27 and paste them into sheet 4 starting on row 21.

    The data ranges vary within sheets 5 - 27. For example, sheet 6 has data in rows 21:50, whereas sheet 10 has data in rows 21:500. I chose 21:1000 as a safe measure to ensure that all data starting on rows 21 onward gets copied.

    I am having trouble thinking of how to create a macro which will copy the data from sheets 5 - 27 and paste into sheet 4 leaving no blank spaces in between pasted rows. Ultimately my goal is to use the filter boxes I have set up in the column headers of sheet 4 to quickly sort all the data pasted from sheets 5 - 27.

    Thanks for your input!

    Nick
    Last edited by Nickster64; 02-19-2009 at 11:17 AM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    3,788

    Re: copy/paste macro...

    Can you explain more about your data or attach an example sheet. Could the data extend across any number of columns? Are there any completely blank rows in your data. If not, then a simple loop through your sheets could add the data to the bottom of sheet4.

  3. #3
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: copy/paste macro...

    Try:

    Private Sub PastetoSheetFour()
    
    Dim i as integer
    
    For i = 5 to 27
         Sheets(i).Activate
         Range("A65536").End(xlup).Select
         Range(Activecell,"A21").Select
         Selection.Copy
         Sheets(4).Activate
         Range("A65536").End(xlup).Offset(1, 0)Select
         ActiveSheet.Paste
    
    Next i
    
    End Sub
    Dave

  4. #4
    Registered User
    Join Date
    11-06-2008
    Location
    Illinois
    Posts
    63

    Re: copy/paste macro...

    Thanks for your responses. Davegugg, I tweaked with your macro and it works great now. Below is what I the final version of it.

    Dim i As Integer                 
    
    For i = 5 To 27                 
         Sheets(i).Activate          
         Range("A21:K1000").Select  
         Selection.Copy              
         Sheets("EngDepts").Select 
         Range("A60000:K60000").End(xlUp).Offset(1, 0).Select  
         ActiveSheet.Paste           
    
    Next i
    Thank you for your help!

    Nick

  5. #5
    Forum Guru davegugg's Avatar
    Join Date
    12-18-2008
    Location
    WI, US
    MS-Off Ver
    2007
    Posts
    1,879

    Re: copy/paste macro...

    Doesn't that put gaps into your data on sheet 4?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0