Paste values code

davez

Board Regular
Joined
Feb 12, 2003
Messages
144
Office Version
  1. 365
Platform
  1. Windows
Hi all, I have this code which works fine for copying ranges from multiple sheets to a Master sheet. What I need to do is paste the values as some of the copied cells do contain formulas & I have played around but cannot work out where to place "PasteSpecial Paste:=xlPasteValues". Thanks for any help provided.

VBA Code:
Sub COPY_RESULTS_TO_MASTER()
Dim ws As Worksheet, lr As Long
lr = Sheets("Master").Cells(Rows.Count, "A").End(xlUp).Row + 1
For Each ws In Worksheets
    If ws.Name <> "Master" Then
        ws.Range("T1:AH60").Copy Sheets("Master").Range("A" & lr)
        lr = Sheets("Master").Cells(Rows.Count, "A").End(xlUp).Row + 1
    End If
Next ws
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Try this:
VBA Code:
Sub COPY_RESULTS_TO_MASTER()
Dim ws As Worksheet, lr As Long
lr = Sheets("Master").Cells(Rows.Count, "A").End(xlUp).Row + 1
For Each ws In Worksheets
    If ws.Name <> "Master" Then
        ws.Range("T1:AH60").Copy
       Sheets("Master").Range("A" & lr).PasteSpecial xlPasteValues
       Application.CutCopyMode = False
        lr = Sheets("Master").Cells(Rows.Count, "A").End(xlUp).Row + 1
    End If
Next ws
End Sub
 
Last edited by a moderator:
Upvote 0
Solution
Try this:
VBA Code:
Sub COPY_RESULTS_TO_MASTER()
Dim ws As Worksheet, lr As Long
lr = Sheets("Master").Cells(Rows.Count, "A").End(xlUp).Row + 1
For Each ws In Worksheets
    If ws.Name <> "Master" Then
        ws.Range("T1:AH60").Copy
       Sheets("Master").Range("A" & lr).PasteSpecial xlPasteValues
       Application.CutCopyMode = False
        lr = Sheets("Master").Cells(Rows.Count, "A").End(xlUp).Row + 1
    End If
Next ws
End Sub

Thanks, I added a full stop before the PasteSpecial to get it running, works well.
 
Upvote 0
I have added the "." to post #2 and marked that as the solution since that post was the gist of the answer & would help future readers the best. :)
 
Upvote 0

Forum statistics

Threads
1,215,136
Messages
6,123,249
Members
449,093
Latest member
Vincent Khandagale

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