Stop a toggle button from increases file size

KDH

New Member
Joined
Mar 31, 2011
Messages
1
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

 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Forum statistics

Threads
1,224,592
Messages
6,179,787
Members
452,942
Latest member
VijayNewtoExcel

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top