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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to make macros unspecific ??? 2

Status
Not open for further replies.
May 2, 2003
175
GB
hi there, can anyone help me here, got a macro here but everything in it is specific to the workbook I'm in, but that is useless to me, because it is also specific to doing that task just once.

How do you use unspecified variables within VBA

Example I want to make it so that you can copy/create a spreadsheet and move it to the last position within the workbook. yet when you do this, in the code it seems to tag onto the names of sheets not the actual sheet itself.

Can anyone shed any light on this one for me?

When student asks a questions, often the most obvious solution is the answer.
 
for this particular example, you can use the sheet index.

Sheets("Sheet1")

is the same as sheets(1)

where the 1st sheet in the workbook is called "Sheet1"

To always refer to the last sheet in a workbook, you can use

Sheets(sheets.count)

to get the name
sheets(sheets.count).name
etc etc

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Thanks, I shall give that a go

When student asks a questions, often the most obvious solution is the answer.
 
thanks it worked, have a star

When student asks a questions, often the most obvious solution is the answer.
 
Hi there, I can't seem to get the syntax of:

Sheets("Sheet1").Select

To work, what is wrong with this?


When student asks a questions, often the most obvious solution is the answer.
 
Sheet1 needs to be the name of the sheet you want to select

Rgds, Geoff
[blue]Si hoc signum legere potes, operis boni in rebus Latinus alacribus et fructuosis potiri potes![/blue]
Want the [red]best[/red] answers to your questions ? faq222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top