Help with Excel VBA in Copy and Paste Values Only, not the formulas

Nestor_Ike

New Member
Joined
Apr 15, 2015
Messages
3
Hello,

The current code copies and paste the results with formulas. Then, it gets really tedious to export the ONLY the values, not the formulas. See the below 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

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
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 <acronym title="visual basic for applications">VBA</acronym> code. Please help.

Thanks,
Nes
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,633
Members
452,661
Latest member
Nonhle

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