Macro issue 2

  • Thread starter Thread starter Farhad
  • Start date Start date
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,
 
Once you have opened a workbook, it becomes the Active workbook. So:

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

should work just fine
 
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
 
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,
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top