Select a worksheet using today's date

Mikeymike15

New Member
Joined
Jul 20, 2006
Messages
33
Hi guys,

My question is:

I'd like my macro to preferably select the worksheet it draws data from, based on today's date.

My workbook is updated every day with a new tab and a new set of data, so on July 2nd, I create a new sheet entitled "0702", however right now I have to go into the macro and adjust the date. I currently have another table that has a date reference (i.e. 7/2/15 which gets converted to 0702)

Thus, below, where it states Sheets("0702").select, I'd like the macro to find sheet 0702 and pick out the tab without me having to manually re-adjust the coding.

Alternatively, I wouldn't mind simply having a pop-up box ask for today's date, which would simplify my steps.

Thanks for any help,
Mike


Sub CMIShort1()

' ***************************************
' ***** CMI Desk PO Shortage Report *****
' ***************************************
' Searches for Matl Help required and pulls back every row to create a report showing oustanding PO's

Dim lastrow As Long
Dim Li As Long

lastrow = Worksheets("CMIShort").Range("A2500").End(xlUp).Row
Sheets("0702").Select
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
This will do it:

Code:
Dim mySheetName As String
Dim mySheet As Worksheet

mySheetName = Format(Month(Now), "00") & Format(Day(Now), "00")
Set mySheet = Sheets(mySheetName)

mySheet.Select
 
Upvote 0
try:

Code:
Sheets(Format(Date, "mmdd")).Select

Dave
 
Upvote 0
Try this:

Code:
Dim str As String
str = InputBox("Please insert the date in format MMDD:", "Insert Date")

Sheets(str).Select
 
Upvote 0

Forum statistics

Threads
1,214,866
Messages
6,121,996
Members
449,060
Latest member
mtsheetz

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