SOLVED

Hide First Row of Spreadsheet, when using macro to save CSV file

Iron Contributor

Hi All,

 

I have a macro on the attached which saves information on a tab as a CSV file into a designated folder. The file path for the folder is shown on row 1, then the headings for data start on row 2.

 

Currently when i run the macro it will save the entire sheet, including the filepath in row 1. As this file is used as an upload into various systems, i wish to have the sheet start from row 2 (Headings), and not save row 1.

 

Does anyone have any suggestions on how to approach this?

 

Many thanks,

4 Replies

@calof1 

Change the lines

'Copying data to new sheet
destinationSheet.Range(destinationSheet.Cells(1, sourceStartCol), destinationSheet.Cells(sourceEndRow - sourceStartRow, sourceEndCol)).Value = sourceSheet.Range(sourceSheet.Cells(sourceStartRow, sourceStartCol), sourceSheet.Cells(sourceEndRow, sourceEndCol)).Value

to

'Copying data to new sheet
destinationSheet.Range(destinationSheet.Cells(1, sourceStartCol), destinationSheet.Cells(sourceEndRow - sourceStartRow + 1, sourceEndCol)).Value = sourceSheet.Range(sourceSheet.Cells(sourceStartRow, sourceStartCol), sourceSheet.Cells(sourceEndRow, sourceEndCol)).Value
Hi Hans,

Thanks for your assistance, very much appreciated. I have updated the row, i still find i have the top rows information shows on my data file. Do you have any ideas of what i have done incorrectly updating this?

Many thanks for all your help.
best response confirmed by calof1 (Iron Contributor)
Solution

@calof1 I think the problem was that you activate the source sheet. Plus sourceStartRow should be 4.

Hi Hans,

Thanks again for your help with this, very much appreciated.

This is now working exactly as i had hoped.

Many thanks,
1 best response

Accepted Solutions
best response confirmed by calof1 (Iron Contributor)
Solution

@calof1 I think the problem was that you activate the source sheet. Plus sourceStartRow should be 4.

View solution in original post