VB code to paste values

pagrender

Well-known Member
Joined
Sep 3, 2008
Messages
652
Hello all,

I'm using the following code to paste data from all sheets onto one sheet. Is there a way to alter this code so it pastes as values? This code is bringing in some formulas and I would like to have values instead.


Dim i As Integer, lr As Long, lr2 As Long

For i = 1 To Sheets.Count
If IsError(Application.Match(Sheets(i).Name, Array("AllData", "Totals", "LBA"), 0)) Then
lr = Sheets(i).Cells(Rows.Count, "A").End(xlUp).Row
lr2 = Sheets("AllData").Cells(Rows.Count, "A").End(xlUp).Offset(1).Row
Sheets(i).Range("A1:H" & lr).Copy Destination:=Sheets("AllData").Range("A" & lr2)
End If
Next i
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
How's this:

Code:
Sheets(i).Range("A1:H" & lr).Copy
        Sheets("AllData").Range("A" & lr2).PasteSpecial Paste:=xlPasteValues

HTH,
 
Upvote 0
Try

Code:
Dim i As Integer, lr As Long, lr2 As Long

For i = 1 To Sheets.Count
    If IsError(Application.Match(Sheets(i).Name, Array("AllData", "Totals", "LBA"), 0)) Then
        lr = Sheets(i).Cells(Rows.Count, "A").End(xlUp).Row
        lr2 = Sheets("AllData").Cells(Rows.Count, "A").End(xlUp).Offset(1).Row
        Sheets(i).Range("A1:H" & lr).Copy
        Sheets("AllData").Range("A" & lr2).PasteSpecial Paste:=xlPasteValues
    End If
Next i
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,176
Members
452,893
Latest member
denay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top