Tosborn
New Member
- Joined
- May 24, 2016
- Messages
- 44
hey all,
Have some code that saves the one sheet as a new workbook which is cool. However I’d like to utilise a For – If loop to save every worksheet in that range to a new workbook.
I’m learning VBA (slowly but surely) hahaa, but would really appreciate some assistance on this one.
Cheers,
Tim
Have some code that saves the one sheet as a new workbook which is cool. However I’d like to utilise a For – If loop to save every worksheet in that range to a new workbook.
Code:
Sub SaveSheet()
'
'Save single sheet as new workbook
'
Dim rcell As Range
Dim Background As Worksheet
Set Background = ActiveSheet
'For Each rcell In Range("i2:i40")
'If rcell.Value <> "" Then
ActiveSheet.Copy
Set WB = ActiveWorkbook
'Save without formulas ?
Cells.Copy
Cells.PasteSpecial Paste:=xlPasteValues
'Clear the clipboard
Application.CutCopyMode = False
Range("d13").Select
'savefilename
FileName = Cells(1, "D").Value & ".xlsx"
'Continue when error occurs
On Error Resume Next
Kill "h:\" & FileName
On Error GoTo 0
WB.SaveAs FileName:="e:\vba\" & FileName
End Sub
I’m learning VBA (slowly but surely) hahaa, but would really appreciate some assistance on this one.
Cheers,
Tim