Macro to Select last sheet with data in a workbook

jmh1

New Member
Joined
Aug 4, 2005
Messages
43
How can i write a macro that will paste data into the last sheet with data in a workbook? I have a workbook with 31 sheets (1 for each day of the month) and everyday i want to paste data into the sheet for that day. paste into sheet 1 on the 1st, 2 on the 2nd, etc..

How can i write a macro that will automate that process?
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
How about something like this:
Code:
Sub dates()

Dim MyStr As Integer

MyStr = Format(Now, "dd")
Sheets("Sheet" & MyStr).Select

End Sub
If the sheets are named Sheet1, Sheet2,...,Sheet31:
When the macro is run, if it is December 22, Sheet22 will be selected.

I dont know where or what you will be pasting, but that code will have to be added at the end of this code.
 
Upvote 0

Forum statistics

Threads
1,215,575
Messages
6,125,618
Members
449,238
Latest member
wcbyers

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