Macro issue 2

F

Farhad

Hi all,

my problem is to know how can i activate the last tab of an excel file in my
code i am openning several excel files one by one (not at the same time) in
my code and need to activate the last tab of each of them when the file is
open i am usung the code below which i found in MS Excel help but it doesn't
work everyone help me please.

ActiveWindow.ScrollWorkbookTabs Position:=xlLast

thanks,
 
G

Gary''s Student

Once you have opened a workbook, it becomes the Active workbook. So:

Sub lastone()
Sheets(Sheets.Count).Activate
End Sub

should work just fine
 
S

Simon Lloyd

You can use this:

Code:
--------------------
Sheets(Sheets.Count).Select
--------------------
you can use Activate rahther than Select if you wish!


--
Simon Lloyd

Regards,
Simon Lloyd
'The Code Cage' (http://www.thecodecage.com)
 
F

Farhad

Thanks Gary! it worked great
--
Farhad Hodjat


Gary''s Student said:
Once you have opened a workbook, it becomes the Active workbook. So:

Sub lastone()
Sheets(Sheets.Count).Activate
End Sub

should work just fine
 
F

Farhad

You're Welcome! i have another question how can i check a tab in a excel file
say tab "aaa" if it is exist in the file or not? sorry bugging you again i am
very new in VBA and need to learn.

Thanks,
 
G

Gary''s Student

Function SheetExists(SheetName As String) As Boolean
On Error Resume Next
SheetExists = CBool(Len(ThisWorkbook.Worksheets(SheetName).Name))
End Function


so =sheetexists("aaa") will return True if the sheets exists.
 
Top