Macro to format a sheet with variable # of rows

Alex881

New Member
Joined
May 6, 2019
Messages
39
I'm new to Macros, but I'm trying to write one that does the same formatting (e.g., bolds columns, adds a total, adds a column, etc) regardless of the number of rows. The data I'm working with will have a different number of rows each time, but the columns remain the same. I was wondering how to go about writing one. I've used the record macro feature with relative references enabled, but I can only get decent results using data that has the exact same number of rows. If I change the data and the number of rows I'm working with, the macro doesn't work properly. Maybe there's a tutorial for this sort of thing? That would help me out a lot.

Thanks! :)
 
Thanks so much, Dante.

That's working quite well, actually. Only a few small formatting things I'd change, if I need to.

It works with both the ones with a total and the ones without a total. Really fascinating stuff.

I may update this thread if I have any other small changes, but really - thanks so much for the help. I'm glad to have something working well for a formerly tedious task!
 
Upvote 0

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Thanks so much, Dante.

That's working quite well, actually. Only a few small formatting things I'd change, if I need to.

It works with both the ones with a total and the ones without a total. Really fascinating stuff.

I may update this thread if I have any other small changes, but really - thanks so much for the help. I'm glad to have something working well for a formerly tedious task!


I'm glad to help you. I appreciate your kind comments.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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