Adjust macro to copy values not formulas

ste33uka

Active Member
Joined
Jan 31, 2020
Messages
471
Office Version
  1. 365
Platform
  1. Windows
I have the following macro that copies data from current worksheet to worksheet called DATA MONTHLYS when cell nx1 = xxxxxx.
But currently it copies formulas, is there a way to make it copy the values made via the formulas.
Thanks

VBA Code:
Sub DataMonthlys()
   Dim i As Long
  
   For i = 1 To 60
      With Sheets(CStr(i))
         If LCase(.Range("nx1").Value) = "yes" Then
            .Range("tn4:tp75").Copy Workbooks("DATA MONTHLYS").Sheets("SHEET1").Range("a" & Rows.Count).End(xlUp).Offset(1)
            .Range("uv4:uw289").Copy Workbooks("DATA MONTHLYS").Sheets("SHEET1").Range("d" & Rows.Count).End(xlUp).Offset(1)
         ElseIf LCase(.Range("nx1").Value) = "no" Then
            .Range("tn4:tp75").Copy Workbooks("DATA MONTHLYS").Sheets("SHEET2").Range("a" & Rows.Count).End(xlUp).Offset(1)
            .Range("uv4:uw289").Copy Workbooks("DATA MONTHLYS").Sheets("SHEET2").Range("d" & Rows.Count).End(xlUp).Offset(1)
         End If
      End With
   Next i
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.
You can split it into two rows as below:

VBA Code:
.Range("tn4:tp75").Copy
Workbooks("DATA MONTHLYS").Sheets("SHEET1").Range("a" & Rows.Count).End(xlUp).Offset(1).PasteSpecial xlpastevalues
 
Upvote 0
Solution
Or, alternatively, try replacing...

VBA Code:
.Range("tn4:tp75").Copy Workbooks("DATA MONTHLYS").Sheets("SHEET1").Range("a" & Rows.Count).End(xlUp).Offset(1)

with

VBA Code:
With .Range("tn4:tp75")
    Workbooks("DATA MONTHLYS").Sheets("SHEET1").Range("a" & Rows.Count).End(xlUp).Offset(1).Resize(.Rows.Count, .Columns.Count).Value = .Value
End With


And, the same thing for the rest.

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,214,921
Messages
6,122,280
Members
449,075
Latest member
staticfluids

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