copy and paste VALUES ONLY, not the formulas.

Nestor_Ike

New Member
Joined
Apr 15, 2015
Messages
3
Hello,

The current code copies and pastes the results with formulas. Then, it gets really tedious to export the worksheets to a new workbook as the worksheets lose formula references. I need to be able to copy and paste VALUES ONLY, not the formulas. See the above VBA code. Please help.

Thanks,
Nes
=================
Sub CreateSheets()
Dim rng As Range
Dim wkb As Workbook
Dim wks As Worksheet
Dim wksData As Worksheet
Dim strwks As String
Set wkb = ActiveWorkbook
Set wksData = wkb.Sheets("Loss_Calculations")
strwks = ""
On Error GoTo ErrorHandler
For Each wks In wkb.Sheets
strwks = strwks & " " & wks.Name
Next wks
'For Each rng In wksData.Range("A12:A" & wksData.Range("A" & wksData.Rows.Count).End(xlUp).Row).SpecialCells(xlCellTypeVisible)
' If InStr(1, strwks, rng.Value) > 0 Then
' 'do nothing
' Else
' wkb.Sheets("AcctTemplate").Copy After:=wkb.Sheets(wkb.Sheets.Count)
' wkb.Sheets(wkb.Sheets.Count).Name = rng.Value
' End If
'Next rng
For Each rng In wksData.Range("A12:A" & wksData.Range("A" & wksData.Rows.Count).End(xlUp).Row)
If rng.EntireRow.Hidden = False Then
If InStr(1, strwks, rng.Value) > 0 Then
'do nothing
Else
wkb.Sheets("AcctTemplate").Copy After:=wkb.Sheets(wkb.Sheets.Count)
wkb.Sheets(wkb.Sheets.Count).Name = rng.Value
End If
Else: End If
Next rng
ExitClause:
Exit Sub
ErrorHandler:
MsgBox "[" & Error() & "]"
Resume ExitClause

End Sub
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
if you record it in macro recorder you can paste as value, and that will show you the construct of your macro
 
Upvote 0

Forum statistics

Threads
1,215,411
Messages
6,124,759
Members
449,187
Latest member
hermansoa

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