I'm new to VBA.
I use the following macro to copy data from a sheet to a new workbook (then close the sheet without saving):
Sub Copy_To_New_Workbook()
Sheets("Reports").Copy
Workbooks("Template.xlsm").Close SaveChanges:=False
End Sub
I hope someone can help with the following:
1) When the data is pasted to the new workbook, it has 1048576 rows despite there are only a few hundred rows with data. Is there a way to modify my macro above so that the new workbook would only contain rows with data?
2) How can I modify the above code so that I don't have to refer to the file name ("Template.xlsm") to close it?
Hope someone can help with these silly questions (again, I'm only starting to learn VBA).
I use the following macro to copy data from a sheet to a new workbook (then close the sheet without saving):
Sub Copy_To_New_Workbook()
Sheets("Reports").Copy
Workbooks("Template.xlsm").Close SaveChanges:=False
End Sub
I hope someone can help with the following:
1) When the data is pasted to the new workbook, it has 1048576 rows despite there are only a few hundred rows with data. Is there a way to modify my macro above so that the new workbook would only contain rows with data?
2) How can I modify the above code so that I don't have to refer to the file name ("Template.xlsm") to close it?
Hope someone can help with these silly questions (again, I'm only starting to learn VBA).