ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   active worksheet (https://www.excelbanter.com/excel-programming/440667-active-worksheet.html)

Matthew Dyer

active worksheet
 
Set wb2 = Workbooks("LESTER, BRENDA.xls")


how do I replace the above code to set wb2 as the active sheet?

[email protected]

active worksheet
 
Try...

Windows(wb2).Activate


On Mar 15, 10:00*pm, Matthew Dyer wrote:
Set wb2 = Workbooks("LESTER, BRENDA.xls")

how do I replace the above code to set wb2 as the active sheet?


Matthew Herbert[_3_]

active worksheet
 
Matthew,

Try the following:

Dim Wks As Worksheet
Set Wks = ActiveSheet

(Note that if you don't specifically state the qualifing hierarchy, Excel
will build the hierarchy for you. For example, "Set Wks = ActiveSheet" will
be appended to be ActiveWorkbook.ActiveSheet, whereas something like "Set Wks
= Workbooks("test.xlsx").Worksheets(2)" will reference a specific worksheet
from a specific workbook, regardless of which workbook is currently active).

Best,

Matthew Herbert

"Matthew Dyer" wrote:

Set wb2 = Workbooks("LESTER, BRENDA.xls")


how do I replace the above code to set wb2 as the active sheet?
.



All times are GMT +1. The time now is 08:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com