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

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
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,902
Messages
6,122,161
Members
449,069
Latest member
msilva74

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