ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting worksheet name equal to variable value (https://www.excelbanter.com/excel-programming/379308-setting-worksheet-name-equal-variable-value.html)

newguy

Setting worksheet name equal to variable value
 
I have several worksheets in my workbook and need to input information
into a worksheet based on the date entered by the user. the worksheets
are name 01-Dec-06 up too 31-Dec-06 in order. The user in most cases
will enter the information in order meaning after they enter the
information on the 1st they will then input the information on the 2nd.
But they could possibly do them out of order if they wanted. That is
why I am trying to select the worksheet based on the date entered since
the worksheet names and the date entered are formated the same. Here is
my process so far for doing this.

I have a Variable newwrksheet and a Variable of type string called
TodaysDate

I have tried worksheets(newwrksheets).name = TodaysDate and it gives me
an error because the types are a mismatch.



Any Help would be greatly appreaciated


Martin Fishlock

Setting worksheet name equal to variable value
 
Are you trying to select that entered worksheet if so try

worksheets(format(TodaysDate, "dd-mm-yy")).select

you say that the names of the worksheets are already the dates so

worksheets(format(TodaysDate, "dd-mm-yy")).name = format(TodaysDate,
"dd-mm-yy")

will just set the name the same.

Please explain for if you need further help.
--
Hope this helps
Martin Fishlock
Please do not forget to rate this reply.


"newguy" wrote:

I have several worksheets in my workbook and need to input information
into a worksheet based on the date entered by the user. the worksheets
are name 01-Dec-06 up too 31-Dec-06 in order. The user in most cases
will enter the information in order meaning after they enter the
information on the 1st they will then input the information on the 2nd.
But they could possibly do them out of order if they wanted. That is
why I am trying to select the worksheet based on the date entered since
the worksheet names and the date entered are formated the same. Here is
my process so far for doing this.

I have a Variable newwrksheet and a Variable of type string called
TodaysDate

I have tried worksheets(newwrksheets).name = TodaysDate and it gives me
an error because the types are a mismatch.



Any Help would be greatly appreaciated



newguy

Setting worksheet name equal to variable value
 
That worked Thank You

Martin Fishlock wrote:
Are you trying to select that entered worksheet if so try

worksheets(format(TodaysDate, "dd-mm-yy")).select

you say that the names of the worksheets are already the dates so

worksheets(format(TodaysDate, "dd-mm-yy")).name = format(TodaysDate,
"dd-mm-yy")

will just set the name the same.

Please explain for if you need further help.
--
Hope this helps
Martin Fishlock
Please do not forget to rate this reply.


"newguy" wrote:

I have several worksheets in my workbook and need to input information
into a worksheet based on the date entered by the user. the worksheets
are name 01-Dec-06 up too 31-Dec-06 in order. The user in most cases
will enter the information in order meaning after they enter the
information on the 1st they will then input the information on the 2nd.
But they could possibly do them out of order if they wanted. That is
why I am trying to select the worksheet based on the date entered since
the worksheet names and the date entered are formated the same. Here is
my process so far for doing this.

I have a Variable newwrksheet and a Variable of type string called
TodaysDate

I have tried worksheets(newwrksheets).name = TodaysDate and it gives me
an error because the types are a mismatch.



Any Help would be greatly appreaciated





All times are GMT +1. The time now is 05:07 PM.

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