hajduk1908
New Member
Hello Expert
I have a macro to perform a function, essentially it will delete a certain number of rows then export the remaining worksheet as a csv. I was wondering if I could put a reset button on it so if the user made a mistake they could start again, ideally a drop list for example I could put at the start of the workbook. for
I have 20 worksheet. When I reset it means back to pre-macro run state.
Thanks
eg.
Reset Worksheet Orange
Reset Worksheet Black
Reset Worksheet Red
The following is an example Worksheet Orange that I use to delete the first 11 rows and save the rest of it as a CSV. I have used the recorder function in excel but unfortunately when replayed all the colours and writing are hardly legible
I have a macro to perform a function, essentially it will delete a certain number of rows then export the remaining worksheet as a csv. I was wondering if I could put a reset button on it so if the user made a mistake they could start again, ideally a drop list for example I could put at the start of the workbook. for
I have 20 worksheet. When I reset it means back to pre-macro run state.
Thanks
eg.
Reset Worksheet Orange
Reset Worksheet Black
Reset Worksheet Red
The following is an example Worksheet Orange that I use to delete the first 11 rows and save the rest of it as a CSV. I have used the recorder function in excel but unfortunately when replayed all the colours and writing are hardly legible
Code:
Sub Delete_Rows11_Loop()
ActiveWorkbook.Save
Dim WS As Worksheet
Dim path As String
path = ActiveWorkbook.path & "\" & Left(ActiveWorkbook.Name, InStr(ActiveWorkbook.Name, ".") - 1)
' Loop through all selected sheets.
For Each WS In ActiveWindow.SelectedSheets
WS.Rows("1:11").Delete ' delete 11 rows at top of each sheet.
WS.Copy
Range("A1:A" & ActiveSheet.Cells.SpecialCells(xlCellTypeLastCell).Row).Select 'select relevant cells
Selection.SpecialCells(xlBlanks).EntireRow.Delete 'remove empty rows
ActiveWorkbook.SaveAs Filename:=path & "_" & WS.Name & ".csv", FileFormat:=xlCSV, CreateBackup:=False
ActiveWorkbook.Close SaveChanges:=False
Next WS
MsgBox "Done! Please exit without saving"
MsgBox "If you have problems importing run the CleanCSV function and retry inport into PBRC"
End Sub
Last edited by a moderator: