tonywatsonhelp
Well-known Member
- Joined
- Feb 24, 2014
- Messages
- 3,194
- Office Version
- 365
- 2019
- 2016
- Platform
- Windows
hi everyone,
The code below works great, but it copies everything, i just want it to copy values
any ideas what bit i need to change?
thanks
Tony
the code:
The code below works great, but it copies everything, i just want it to copy values
any ideas what bit i need to change?
thanks
Tony
the code:
VBA Code:
Sub AllReports()
Dim fPath As String
Dim wb As Workbook, data As Worksheet, raw As Worksheet, rng As Range, cel As Range, C8 As Range
Set data = Sheets("Data Inputs")
Set C8 = data.Range("C8")
Set raw = Sheets("Raw Data")
Set rng = raw.Range("C8:C" & LrowA)
'create folder if required
fPath = ThisWorkbook.Path & "\All Reports"
If Dir(fPath, vbDirectory) = "" Then MkDir fPath
fPath = fPath & "\"
'save each workbook
If Application.Wait(Now + TimeValue("0:00:02")) Then
Application.StatusBar = "Creating new workbooks"
For Each cel In rng
cel.Resize(, 69).Copy C8 ''I think this is the part that should be values only?
DoEvents
ThisWorkbook.SaveCopyAs fPath & C8 & ".xlsm"
Next
End If
Application.StatusBar = False
'open each workbook and delete sheet Raw Data
For Each cel In rng
Application.ScreenUpdating = False
Application.StatusBar = "Deleting Raw Data in " & fPath & cel
Set wb = Workbooks.Open(fPath & cel & ".xlsm")
DoEvents
Application.DisplayAlerts = False
wb.Sheets("Raw Data").Delete
Application.DisplayAlerts = True
wb.Close (True)
DoEvents
Next cel
MsgBox "done", , ""
Application.StatusBar = False
End Sub