+ Reply to Thread
Results 1 to 6 of 6

Macro to copy and paste sepcial into next blank row

Hybrid View

  1. #1
    Registered User
    Join Date
    06-15-2012
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2010
    Posts
    46

    Macro to copy and paste sepcial into next blank row

    I have 12 sheets of data that I would like to collate into one sheet (sheet 13), I must be over looking something because I just cant seem to get this to work. Please review my code below, it hangs at the last line, what am I missing?
    Sub Collate_data()
    
    'Clear all content in Sheet 13
    Sheets(13).Range("A2:S5000").Clear
    
    Application.ScreenUpdating = False
     
    'Collate data
    Sheets(1).Range("A3:S5000").Copy
    Sheets(13).Range("A2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    Sheets(2).Range("A3:S5000").Copy
    Sheets(13).Range("A" & Rows.Count).End(xlUp).Offset(1).PasteSepcial Paste:=xlPasteValuesAndNumberFormat, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    I hope someone can help me with this.
    Thanks in advance for your help

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro to copy and paste sepcial into next blank row

    PasteSepcial should be PasteSpecial. There might be more than that wrong but its what i see from first glance.

    Note: It appears as though you are going to be copying the same range across all worksheets but number 13. Here is a quick way to do that

    Sub Collate_data()
    Dim wksht As Worksheet
    Dim LR As Long
    
    'Clear all content in Sheet 13
    Sheets(13).UsedRange.ClearContents
    
    Application.ScreenUpdating = False
    
    'Collate data
    For Each wksht In Worksheets
        If wksht.Index < 13 Then
            LR = wksht.Range("A" & Rows.Count).End(xlUp).Row
            wksht.Range("A3:S" & LR).Copy
            Sheets(13).Range("A2").PasteSpecial Paste:=xlPasteValues
        End If
    Next wksht
    
    Application.ScreenUpdating = True
    
    End Sub
    Last edited by stnkynts; 06-10-2013 at 04:21 PM.

  3. #3
    Registered User
    Join Date
    06-15-2012
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Macro to copy and paste sepcial into next blank row

    Thanks stnkynts, Good catch, fixed that but still no luck

  4. #4
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Macro to copy and paste sepcial into next blank row

    where is the rest of your code and what are you trying to do? See added code above to see if it does what you want.

  5. #5
    Registered User
    Join Date
    06-15-2012
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Macro to copy and paste sepcial into next blank row

    Thanks, i think the issue was the paste special function I was using, I tried "xlvalues" instead of "xlPasteValuesAndNumberFormat" and it worked fine. Thanks for your help

  6. #6
    Registered User
    Join Date
    06-15-2012
    Location
    Pennsylvania, USA
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Macro to copy and paste sepcial into next blank row

    Sorry that shld read: I tried "xlPastevalues" instead of "xlPasteValuesAndNumberFormat" and it worked fine

+ 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