Consulting

Results 1 to 5 of 5

Thread: Copy and Paste

  1. #1
    VBAX Regular
    Joined
    Oct 2011
    Posts
    10
    Location

    Copy and Paste

    I found this Code in this Forum, and I was hoping that someone could help me change it to paste Values.

      
    Sub CopySheets()
    ' stanleydgrom, 12/02/2009
    Dim MySheets As Variant, LR As Long, NR As Long, a As Long
    MySheets = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5")
    Application.ScreenUpdating = False
    NR = 2
    For a = LBound(MySheets) To UBound(MySheets)
    With Sheets(MySheets(a))
    LR = .Cells(Rows.Count, "V").End(xlUp).Row
    .Range("C10:V" & LR).Copy Sheets("Summary").Range("A" & NR)
    End With
    NR = NR + LR - 10 + 1
    Next a
    Sheets("Summary").Select
    Application.ScreenUpdating = True
    End Sub
    Thank you in advance.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Sub CopySheets()
    ' stanleydgrom, 12/02/2009
    Dim MySheets As Variant, LR As Long, NR As Long, a As Long
    
        MySheets = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5")
    
        Application.ScreenUpdating = False
    
        NR = 2
    
        For a = LBound(MySheets) To UBound(MySheets)
    
          With Sheets(MySheets(a))
    
            LR = .Cells(Rows.Count, "V").End(xlUp).Row
            With .Range("C10:V" & LR)
            
                .Copy Sheets("Summary").Range("A" & NR)
                .Value = .Value
            End With
          End With
    
          NR = NR + LR - 10 + 1
        Next a
    
        Sheets("Summary").Select
    
        Application.ScreenUpdating = True
    End Sub
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Oct 2011
    Posts
    10
    Location
    Thank you xld,

    Your Code copies the Formula to the destination sheet and not the value.

  4. #4
    VBAX Expert
    Joined
    Sep 2016
    Posts
    788
    Location
    Sub CopySheets()
    ' stanleydgrom, 12/02/2009
        Dim MySheets As Variant, LR As Long, NR As Long, a As Long
        
        MySheets = Array("Sheet1", "Sheet2", "Sheet3", "Sheet4", "Sheet5")
        Application.ScreenUpdating = False
        NR = 2
        For a = LBound(MySheets) To UBound(MySheets)
          With Sheets(MySheets(a))
            LR = .Cells(Rows.Count, "V").End(xlUp).Row
            .Range("C10:V" & LR).Copy
            Sheets("Summary").Range("A" & NR).pastespecual xlPasteValues
          End With
          NR = NR + LR - 10 + 1
        Next a
        Application.DataEntryMode = False
        
        Sheets("Summary").Select
        Application.ScreenUpdating = True
        
    End Sub

  5. #5
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,645
    Sub M_snb()
      for each it in sheets
        if it.name <>"Summary" then sheets("summary").cells(rows.count,1).end(xlup).offset(1).resize(it.usedrange.rows.count,it.usedrange.columns.count)=it.usedrange.value
      next
    End Sub

Posting Permissions

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