Hi,
I have a multisheet workbook that I am trying to export out to individual csv files. Within the worksheet I have a column with VLOOKUP values. When I SaveAs from the file menu, everything is perfect! However, when I export to csv from vba - I get the #REF! values where my VLOOKUP should be. help!
I have a multisheet workbook that I am trying to export out to individual csv files. Within the worksheet I have a column with VLOOKUP values. When I SaveAs from the file menu, everything is perfect! However, when I export to csv from vba - I get the #REF! values where my VLOOKUP should be. help!
Code:
Sub CSV_Export()
Dim newWks As Worksheet
Dim wks As Worksheet
ActiveWorkbook.Save
' Get path to the current location of the IOMux excel sheet.
Dim withoutParts As String
withoutParts = Replace(ThisWorkbook.FullName, ThisWorkbook.Name, "")
Application.DisplayAlerts = False
For Each wks In ActiveWorkbook.Worksheets
If InStr("Instructions", wks.Name) = 0 Then
wks.Copy 'to a new workbook
Set newWks = ActiveSheet
With newWks
.SaveAs Filename:=withoutParts & wks.Name, FileFormat:=xlCSV
.Parent.Close savechanges:=False
End With
End If
Next wks
Application.DisplayAlerts = True
MsgBox "done with: " & ActiveWorkbook.Name
End Sub