Hi all,
I'm new to this forum, so please excuse me if I am missing out on anything with my post. I need your help with creating a VBA code that allows me to export 2 worksheets from a binary file into a normal .xlsx file - but exporting only values. I've already created a macro using some YT tutorial, but I can't figure out how to make it export values only. Any advice would be greatly appreciated!
I'm new to this forum, so please excuse me if I am missing out on anything with my post. I need your help with creating a VBA code that allows me to export 2 worksheets from a binary file into a normal .xlsx file - but exporting only values. I've already created a macro using some YT tutorial, but I can't figure out how to make it export values only. Any advice would be greatly appreciated!
VBA Code:
Sub ExportWorkSheets()
Dim wbSource As Workbook, wbTarget As Workbook
Dim worksheetList As String
Dim workshetArr As Variant
Dim i As Long
On Error GoTo errHandle
worksheetList = "Orders:Sales YTD"
worksheetarr = Split(worksheetList, ":")
If UBound(worksheetarr) = -1 Then Exit Sub
Set wbSource = ThisWorkbook
Set wbTarget = Workbooks.Add
For i = LBound(worksheetarr) To UBound(worksheetarr)
wbSource.Worksheets(worksheetarr(i)).Copy wbTarget.Worksheets(wbTarget.Worksheets.Count)
Next i
MsgBox "Export complete.", vbInformation
CleanObject:
Set wbSource = Nothing
Set wbTarget = Nothing
Exit Sub
errHandle:
MsgBox "Error: " & Err.Description, vbExclamation
End Sub