Hello,
I've got a workbook that I need to send to lots of external organisations, for them to complete and email back every quarter. The file size is 0.9MB, but when opened and a toggle button is used to sort rows, when saved the file size shoots up to over 2MB.
From reading a number of other threads, I've worked out the problem can be solved by deleting and clearing the contents of all empty rows. I recorded a macro to do this, which works fine, but I'm coming unstuck when trying to paste the macro into the VBA for the toggle button.
Can anyone help? I'm not experienced with VBA so please excuse my ignorance.
The existing toggle button VBA pasted below. How should I modify this to delete/clear the contents of all empty rows and columns.
Thanks
Kev
Private Sub ToggleButton5_Click()
If ToggleButton5.Value = True Then
With ActiveSheet
If .ProtectContents Then .Unprotect Password:="boris" Else .Unprotect Password:="boris"
End With
Rows("40:539").Select
Selection.Sort Key1:=Range("d40"), Order1:=xlDescending, Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("e36").Select
With ActiveSheet
If .ProtectContents Then .Protect Password:="boris" Else .Protect Password:="boris"
End With
Else
With ActiveSheet
If .ProtectContents Then .Unprotect Password:="boris" Else .Unprotect Password:="boris"
End With
Rows("40:539").Select
Selection.Sort Key1:=Range("g40"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("e36").Select
With ActiveSheet
If .ProtectContents Then .Protect Password:="boris" Else .Protect Password:="boris"
End With
End If
End Sub
I've got a workbook that I need to send to lots of external organisations, for them to complete and email back every quarter. The file size is 0.9MB, but when opened and a toggle button is used to sort rows, when saved the file size shoots up to over 2MB.
From reading a number of other threads, I've worked out the problem can be solved by deleting and clearing the contents of all empty rows. I recorded a macro to do this, which works fine, but I'm coming unstuck when trying to paste the macro into the VBA for the toggle button.
Can anyone help? I'm not experienced with VBA so please excuse my ignorance.
The existing toggle button VBA pasted below. How should I modify this to delete/clear the contents of all empty rows and columns.
Thanks
Kev
Private Sub ToggleButton5_Click()
If ToggleButton5.Value = True Then
With ActiveSheet
If .ProtectContents Then .Unprotect Password:="boris" Else .Unprotect Password:="boris"
End With
Rows("40:539").Select
Selection.Sort Key1:=Range("d40"), Order1:=xlDescending, Header:=xlGuess _
, OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("e36").Select
With ActiveSheet
If .ProtectContents Then .Protect Password:="boris" Else .Protect Password:="boris"
End With
Else
With ActiveSheet
If .ProtectContents Then .Unprotect Password:="boris" Else .Unprotect Password:="boris"
End With
Rows("40:539").Select
Selection.Sort Key1:=Range("g40"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("e36").Select
With ActiveSheet
If .ProtectContents Then .Protect Password:="boris" Else .Protect Password:="boris"
End With
End If
End Sub