Need help in combine Macro's

VinodKrishnappa

New Member
Joined
Aug 6, 2016
Messages
31
I want to combine two macros which are as follows

I've following macro to print letters with a data available in data sheet...

Sub PrintForms()
Dim StartRow As Integer
Dim EndRow As Integer
Dim Msg As String
Dim i As Integer

Sheets("Form").Activate
StartRow = Range("StartRow")
EndRow = Range("EndRow")

If StartRow > EndRow Then
Msg = "ERROR" & vbCrLf & "The starting row must be less than the ending row!"
MsgBox Msg, vbCritical, APPNAME
End If

For i = StartRow To EndRow
Range("RowIndex") = i
If Range("Preview") Then
ActiveSheet.PrintPreview
Else
ActiveSheet.PrintOut
End If
Next i
End Sub


I have following macros to hide the entire rows if the value is 0 in a particular cell.

Sub Hide_Zeroed_Rows()
Dim cell As Range
Application.ScreenUpdating = False
For Each cell In Intersect(ActiveSheet.UsedRange, Range("A1:A11"))
cell.EntireRow.Hidden = cell.Value = 0 And Not IsEmpty(cell)
Next cell
Application.ScreenUpdating = True
End Sub

now i want this Hide_Zeroed_Rows macro to be combined with Printforms macro

I want this both macros to be processed at once...
Can you please help me ion this....
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hello,

if you want to run more macros at once, for example by one click on button just call them one by one in another one. For example:

Code:
sub Both_together()

call PrintForms
call Hide_Zeroed_Rows

end sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,339
Messages
6,124,363
Members
449,155
Latest member
ravioli44

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