Auto Print Button with auto hide and unhide vba

Diankathrine

New Member
Joined
Oct 27, 2017
Messages
2
Hi,
I'm new in VBA, I've been searching the internet to solve my problems in excel. I'm preparing a Payslip sheet which contains a Command Button which automatically prints all the payslips.
The sheet contains salary benefits which other employees don't have. Let's say employee 1 is entitled to school fees (meaning the cells contain figures) while employee 2 is not (which means the cell contains 0) so i want to automatically hide the row of an empty or 0 cell value. My problem is how do I automatically hide and unhide rows while at the same time automatically printing the payslips? I will highly appreciate any help.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
hi and welcome to the forum.

not knowing your code, i can suggest you look at the .RowHeight property.

eg MySheet.Rows(5).Rowheight = 0 will set that row to 0 height

eg
Code:
    If cells(9,4) = 0  Then       ' the school fees are in D9 and equal to 0
        Rows(9).RowHeight = 0
    Else
        Rows(9).RowHeight = 11
    End If
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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