Combine several macros into one

Shadkng

Active Member
Joined
Oct 11, 2018
Messages
365
Hi, I need advice about combining many small macros into one macro. Below are 3 macros that basically do the same thing on different sheets - I have a total of 11 of these macros for 11 sheets. Would it be wiser to combine them into one macro? Right now I have a macro that calls all of them. If so, would I be using the "activate" sheet method or is their a better way. If you could giveme an example on these 3 then I could apply to the rest. Thanks for the help.

VBA Code:
Sub CLUTCH_BUILD_ERASEROW()
Application.ScreenUpdating = False
    Sheets("CLUTCH").Activate
    Range("A32:S5000").Clear
    Range("A25").Select
End Sub

VBA Code:
Sub CUTTER_PROD_ERASEROW()
Application.ScreenUpdating = False
    Sheets("CUTTER").Activate
    Range("A25:Z5000").Clear
    Range("A20").Select
End Sub

VBA Code:
Sub DETAIL_FORM_ERASEROW()
Application.ScreenUpdating = False
    Sheets("DETAIL FORM").Activate
    Range("A31:AE5000").Clear
    Range("A31:AE5000").Interior.color = xlNone
    Range("A11").Select
End Sub
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
It could be done, but I note your ranges for each sheet are different.....can they be rationalised to be the same ??
AND
Is the code applying to ALL sheets in the workbook ?
Try using
VBA Code:
Sub MM1()
Sheets("CLUTCH"). Range("A32:S5000").Clear
Sheets("CUTTER"). Range("A25:Z5000").Clear
Sheets("DETAIL FORM").Range("A31:AE5000").Clear
end Sub
 
Upvote 0
It could be done, but I note your ranges for each sheet are different.....can they be rationalised to be the same ??
AND
Is the code applying to ALL sheets in the workbook ?
Try using
VBA Code:
Sub MM1()
Sheets("CLUTCH"). Range("A32:S5000").Clear
Sheets("CUTTER"). Range("A25:Z5000").Clear
Sheets("DETAIL FORM").Range("A31:AE5000").Clear
end Sub
 
Upvote 0
The ranges must remain as they are because each sheet is different. The code is not applied to all sheets in the workbook, so cannot loop I guess. So your code should work with my current setup?
 
Upvote 0

Forum statistics

Threads
1,213,527
Messages
6,114,144
Members
448,552
Latest member
WORKINGWITHNOLEADER

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