Macro help Please

julievandermeulen

Board Regular
Joined
Jan 25, 2020
Messages
82
Office Version
  1. 365
Platform
  1. Windows
I have a workbook that creates a new sheet every week and is named by the date. Ex 11-11-2021, 11-18-2021, 11-25-2021, etc.

I need to write a macro that will:
Calculate the last 4 sheets
1. look at the names in cells C146:C233 and take the value in that row of column P146:P233 and add the number of the last 4 sheets and put the totals in V146:V233.
2. look at the names in cell C146:C233 and take the value in that row of column Q146:Q233 and add the number of the last 4 sheets and put the totals in W146:W233.
3. look at the names in cell C146:C233 and take the value in that row of column R146:R233 and add the number of the last for sheets and put the total in X146:X233
Calculate the year to date sheets (first sheet of the year through the most recent sheet)
1. look at the names in cells C146:C233 and take the value in that row of column P146:P233 and add the number of the YTD sheets and put the totals in AB146:AB233
2. look at the names in cell C146:C233 and take the value in that row of column Q146:Q233 and add the number of the YTD sheets and put the totals in AC146:AC233.
3. look at the names in cell C146:C233 and take the value in that row of column R146:R233 and add the number of the YTD sheets and put the total in AD146:AD233
Calculate the last 52 sheets
1. look at the names in cells C146:C233 and take the value in that row of column P146:P233 and add the number of the last 52 sheets and put the totals in AH146:AH233
2. look at the names in cell C146:C233 and take the value in that row of column Q146:Q233 and add the number of the last 52 sheets and put the totals in AI146:AI233.
3. look at the names in cell C146:C233 and take the value in that row of column R146:R233 and add the number of the last 52 sheets and put the total in AJ146:AJ233

So far I haven't written any of it, and am new to VBA so I need very detailed explanation. Or if you think I could do it with a formula that would be great as well.
 
I'm going to work on the other workbook that I need help with a macro with. Do you want me to just keep using this thread or start a new one?
 
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Best to start a new post, Julie, then send me a message please so I'll know to look for it.

Happy New Year!

Tony
 
Upvote 0
Happy New Year Tony!!

Thanks so much for helping me. I posted a new thread "Macro with merged cells"
 
Upvote 0
Thanks, Julie.

You have a Merry Christmas too!
Tony

My macro has been working so well until today, when I ran into a problem.
I had to delete a name from column C and add a new name. I've added names and didn't have any problems but when I deleted a name I all of the sudden get a mismatch error. :(
Is there anyway to avoid this?
 
Upvote 0

Forum statistics

Threads
1,224,583
Messages
6,179,681
Members
452,937
Latest member
Bhg1984

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