Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Selecting Last but one worksheet 1

Status
Not open for further replies.

funkmonsteruk

IS-IT--Management
Feb 8, 2002
210
GB
I need to select the last but one worksheet in a workbook - the name of the worksheet changes everyday, but it's position remains constant.

Any Suggestions
 
Just one more thing along the same lines - I need to select columns B:D and insert a name (define as named range).

Using your code i've got

ActiveWorkbook.Sheets(Sheets.Count - 1).Activate
Columns("A:C").Select
ActiveWorkbook.Names.Add Name:=strText1

However my bit of the code doesn't function, any ideas
 
strText is a string and it equals format(Date, "mmmdd")
 
You need to modify it as follows:

activeworkbook.Names.Add Name:=strText1, refersto:="='" & activesheet.name & "'!$A:$C"

Rob
[flowerface]
 
Cheers once again Rob - you really are a life saver and i'm gonna give you a star for this one.....
 
...and what exactly goes wrong, any error messages?
Though I guess this isn't your problem, using
Code:
Sheets(Sheets.Count - 1).Activate
will activate a chart sheet if a chart sheet happens to be the last sheet but 1. In which case there are no columns to select!

To make sure this isn't the problem and it never will be I'd recommend substituting 'Sheets' with 'Worksheets'

Just a thought!
;-) If a man says something and there are no women there to hear him, is he still wrong?
 
There's definately something wrong with my connection!!
3 posts in the time it takes to send one - gotta be a record!

Feel free to ignore me!
;-) If a man says something and there are no women there to hear him, is he still wrong?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top