Forum

Notifications
Clear all

Get Year from Sheet Name, not Cell Reference

8 Posts
2 Users
0 Reactions
214 Views
(@stephanrs)
Posts: 26
Eminent Member
Topic starter
 

1st Date of Year using Tab Ref, not Cell Ref?

For example in Tab TOTAL Cell BF2:
=DATE(YEAR(BG2),1,1)

Hence how to substitute BG2 with TAB YEAR: 2020?

The cause reason is to automate Years Tabs Cell X39, which currently is manually edited date.

Cheers

Stephan

 
Posted : 23/06/2020 10:27 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Stephan,

I'm a bit confused about a few things.

BG2 is labelled 'Today's date' but you want to populate it with a year?

If so you can use a data validation list to choose the year you want to pull data from.

I don't understand why you are asking about cells on the Total sheet when you actually want to automate something on the years sheets.

On the years sheets, just have a cell with the year in it.  This can be referenced by other cells on the same sheet or by cells on other sheets.  I don't see that you need specific cells for the first and last date of the year as these are always Jan 1 and Dec 31.

Regards

Phil

 
Posted : 23/06/2020 11:39 pm
(@stephanrs)
Posts: 26
Eminent Member
Topic starter
 

Hi.

It is 1 only character which I won't overlook.

But what would a Formula look like that could use a tab name as the year?

It does sound trivial and like a great many things, I'm surprised I've not already had the need!

Start & End Date is so when next year comes along the calc won't keep rolling, so to speak.

 

I understand other ppl's work will seem beneath a specialised expert in XL, and guess you must wonder why ppl can't just google, but I don't know the Formula solution or likeky names, but thought the edit suggestion would be a gd start!

But not everything turns out good!

Cheers

 
Posted : 24/06/2020 2:10 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Not at all Stephan, we all learn by doing, reading, Googling etc.  I'm always looking stuff up, I can't remember the syntax for everything 🙂

You can get the name of the current sheet (where the formula resides) using a formula like this

=MID(CELL("filename",A1),FIND("]",CELL("filename",A1))+1,255)

So if you use this on Sheet1, it will return Sheet1.

You can get the name of another sheet, e.g. Sheet2, using this 

=MID(CELL("filename",Sheet2!A1),FIND("]",CELL("filename",Sheet2!A1))+1,255)

But you are including a reference to Sheet2 in that formula so that defeats the purpose as you know the name of the sheet you are trying to get.  You may as well just reference the sheet name directly.

Regards

Phil

 
Posted : 24/06/2020 7:01 pm
(@stephanrs)
Posts: 26
Eminent Member
Topic starter
 

Hi Phil

You are right direct edit of 1 cell 1 character once a year is no big deal!

But feel knowing the answer to this may prove useful in the future, for something else!

Hence maybe I'm asking the wrong question, how about:

WORKSHEET TAB NAME as FORMULA DATE (YEAR)?

Formula suggested:.
= MID(CELL("filename"), 1+SEARCH("]", CELL("filename")), 128)

But it can't be used here as:
1. Not recognised as Date & can't be custom formatted as date.
2. When used on other Worksheets in same Workbook, then unusual side effect, they all reference last worksheet tab formula was last edited/used in.
3. Perhaps this formula is still of use, if can be recognised as date format & "preceded" with:
01-01-YY (ie last 2 digits of worksheet name, they sorted it for the "Year 2000 Millennium Bug" into 4 digit to future proof but just 20th Century is my concern).

Guess somebody has knowledge of a Formula, to do this simple task as to preset Worksheet name as 4digit year as 1st day of that year in 6 digit layout?

Doesn't sound like Mission Impossible to me, I've just not seen it yet....

Hi Phil

You are right direct edit of 1 cell 1 character once a year is no big deal!

But feel knowing the answer to this may prove useful in the future, for something else!

 
Posted : 24/06/2020 8:46 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Stephan

MID returns a string so you need to use DATEVALUE to convert to a date

=DATEVALUE("1/1/"&MID(CELL("filename"), 1+SEARCH("]", CELL("filename")), 128))

Regards

Phil

 
Posted : 24/06/2020 11:17 pm
(@stephanrs)
Posts: 26
Eminent Member
Topic starter
 

Hi Phil, Right I'll try those.....

& also hard to dodge the velocity of this the previous Formula did actually work, the Worksheet Tab name just needed formatting like a date:

01-01 etc

However I found the impact of this making the purpose of each tab more vague & harder to differentiate on 1st impression as all start the same way & wouldn't want the embarrassment & confusion of mixing up 1 year with another totally different year & doing wrong data entry, and not forgetting the anomaly of using same formula more then once on same workbook, hence will try above or just manual etc,

 
Posted : 25/06/2020 2:03 pm
(@stephanrs)
Posts: 26
Eminent Member
Topic starter
 

?? Same error! ??

I'll leave it in MANUAL EDIT for 1st DATE of YEAR, 01-01-YY, totally bullet proof.

Suggested formula have "ricochet" effect, error of duplicating last tab ref'd when used more then once in same workbook in different tabs, hence the opposite of the purpose for seperate totals per "calendar year". And to create defined names, of same formula will just to same unwanted domino effect.

If was sceptical surmise somebody had foreseen use of this & had created a finally anomaly to hinder/prevent "being organised".

Good job I make "backup" of files before working on them, ever such a familiar lifestory of trivial things turning into vast onerousities. If had not have learned from this ever such regular occurence, then would have wasted a lifetime reworking something that was better previously!

Was it like that before? Like that?
Etc 01-01

Thanks for your help, it is bullet proof now, manual edit of 1 character/number once a year it is!

 
Posted : 25/06/2020 7:52 pm
Share: