mattdavid.hall
New Member
- Joined
- Oct 2, 2008
- Messages
- 17
- Office Version
- 365
- Platform
- Windows
We have a script where we export a specific sheet to a new .csv. The problem is that the .csv is taking the cells that have a formula and evaluating it as an empty string.
Here is our script:
Here is what it looks like when we open our file:
The system we are uploading to does not like the empty rows shown in the red box. The sheet can have anywhere from rows 40-200 populated each week, so we copied our formula down to row 200, and the empty rows are what we want to not export.
Is there a way to modify our script to ignore rows in the sheet that have a formula but have no real data when exporting?
Here is our script:
VBA Code:
Public Sub ExportWorksheetAndSaveAsCSV()
Dim wbkExport As Workbook
Dim shtToExport As Worksheet
Set shtToExport = ThisWorkbook.Worksheets("UploadTemplate") 'Sheet to export as CSV
Set wbkExport = Application.Workbooks.Add
xStrDate = Format(Now, "yyyy-mm-dd hh-mm-ss")
shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)
Application.DisplayAlerts = False 'Possibly overwrite without asking
wbkExport.SaveAs Filename:="L:\Human Resources\Y drive files\ADPUpload - " & xStrDate & ".csv", FileFormat:=xlCSV
Application.DisplayAlerts = True
wbkExport.Close SaveChanges:=False
End Sub
Here is what it looks like when we open our file:
The system we are uploading to does not like the empty rows shown in the red box. The sheet can have anywhere from rows 40-200 populated each week, so we copied our formula down to row 200, and the empty rows are what we want to not export.
Is there a way to modify our script to ignore rows in the sheet that have a formula but have no real data when exporting?