ScottGFrustrated
New Member
- Joined
- Oct 12, 2023
- Messages
- 8
- Office Version
- 365
- 2021
- 2019
- Platform
- Windows
I have a simple workbook that I use to enter data and I have macros that send the data to another workbook. The workbook I am sending to must be CSV and the problem I am having is if I only have data in my top row, when it transfers to new workbook, I am getting commas in rows below that. Currently, to bypass this issue, I have to open the CSV workbook, manually select the rows below the data that I need and delete them every time I transfer. I want to be able to click my "Export Data" button and transfer data to the new workbook and ALSO delete any row that contains "<DO NOT CHANGE" in column B.
The data I enter in Worksheet 'Data' automatically transposes to Worksheet 2 'Transfer' and that is where the information for the transfer comes from. I don't want to delete from Worksheet 2 because I have formulas there.
Workbook I enter data in - SFC Transfers
Worksheet it is on - Data
Worksheet 2 - Transfer
Workbook it transfers to - Manualtransfers.csv
My current Macro:
Public Sub XPORTCSV()
Dim wbkExport As Workbook
Dim shtToExport As Worksheet
Dim FPath As String
Dim answer As Integer
Dim RowCount As Long
RowCount = Worksheets("System Settings").Range("A87").Value
Sheets("Transfer").Select
Range("A1:J7").Select
Selection.Copy
FPath = Sheets("System Settings").Range("C2").Text
Set shtToExport = ThisWorkbook.Worksheets("Transfer")
Set wbkExport = Application.Workbooks.Add
shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)
Application.DisplayAlerts = False
wbkExport.SaveAs Filename:=FPath & "\ManualTransfers", FileFormat:=xlCSV
Application.DisplayAlerts = True
wbkExport.Close SaveChanges:=False
End Sub
The data I enter in Worksheet 'Data' automatically transposes to Worksheet 2 'Transfer' and that is where the information for the transfer comes from. I don't want to delete from Worksheet 2 because I have formulas there.
Workbook I enter data in - SFC Transfers
Worksheet it is on - Data
Worksheet 2 - Transfer
Workbook it transfers to - Manualtransfers.csv
My current Macro:
Public Sub XPORTCSV()
Dim wbkExport As Workbook
Dim shtToExport As Worksheet
Dim FPath As String
Dim answer As Integer
Dim RowCount As Long
RowCount = Worksheets("System Settings").Range("A87").Value
Sheets("Transfer").Select
Range("A1:J7").Select
Selection.Copy
FPath = Sheets("System Settings").Range("C2").Text
Set shtToExport = ThisWorkbook.Worksheets("Transfer")
Set wbkExport = Application.Workbooks.Add
shtToExport.Copy Before:=wbkExport.Worksheets(wbkExport.Worksheets.Count)
Application.DisplayAlerts = False
wbkExport.SaveAs Filename:=FPath & "\ManualTransfers", FileFormat:=xlCSV
Application.DisplayAlerts = True
wbkExport.Close SaveChanges:=False
End Sub