ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to find an excel sheet by its name??? (https://www.excelbanter.com/excel-programming/366050-how-find-excel-sheet-its-name.html)

Pedro Miguel C. Silva

How to find an excel sheet by its name???
 
Good evening.

How do I find an Excel Sheet by its name.
For example... I have 10 sheets and I want to find one that fits the
criteria Name=Date().



Dave Peterson

How to find an excel sheet by its name???
 
Depending on your windows setting, you may not be able to name a worksheet based
on the date's value.

I use mm/dd/yyyy as my date format. Excel won't allow those slashes in the
worksheet name.

If I know the format of the date, I can do something like:

dim wks as worksheet
set wks = nothing
on error resume next
set wks = worksheets(format(date,"mm-dd-yyyy"))
on error goto 0

if wks is nothing then
msgbox "not found"
else
msgbox "Found it"
'then use wks in your following code
wks.range("a1").clearcontents 'for example.
end if


You'll want to match the format you expect, though.

"Pedro Miguel C. Silva" wrote:

Good evening.

How do I find an Excel Sheet by its name.
For example... I have 10 sheets and I want to find one that fits the
criteria Name=Date().


--

Dave Peterson


All times are GMT +1. The time now is 02:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com