Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Violet Nelson   on Sep 17 In MS Office Category.

  
Question Answered By: Alisha Johnson   on Sep 17

You said "How do I code  to go to next workbook  or previous  workbook ?" That
is why we were giving you code to do that.

If you want to activate a worksheet  you use

ActiveWorkbook.worksheets("Sheetname").activate

Instead of "Sheetname" you can use a variable which holds a string equal to
the sheet name. You can also use a number representing the position of the
sheet in the workbook but I would only use this if I was cycling through all
the sheets in for loop.

So while you are on the source sheet you could set a variable (say, PWkSheet)
equal to the name of the current worksheet. Then you could use the variable
to activate that sheet.

Sub something()
Dim PWkSheet As String
' other code
PWkSheet = ActiveWorkbook.ActiveSheet.Name
' more code
ActiveWorkbook.Worksheets(PWkSheet).Activate
End Sub

Share: 

 

This Question has 4 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Next Workbook or Previous Workbook Or get search suggestion and latest updates.


Tagged: