ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How do I switch between windows in the active workbook inside a M. (https://www.excelbanter.com/excel-programming/322428-how-do-i-switch-between-windows-active-workbook-inside-m.html)

kdreyer

How do I switch between windows in the active workbook inside a M.
 
How do I switch between windows in the active workbook inside a Macro.

I have a Macro that reformats how ever I need it to do that in Window 2 of
the active workbook. I cannot have it file specific. It needs to take the
active filename and drop it into the formula.

Here is what I have so far. This works but I cannot figure out how to get
the active filename.:

Windows("FS Side Vent.xls:2").Activate
Sheets("Print").Select
Range("OrderNo").Select
Cells.Select
Selection.EntireRow.Hidden = False
For I = 1 To 800
Range("A" & I).Select
If ActiveCell.Value = "0" Then
Selection.EntireRow.Hidden = True
Else
End If

Next I

Range("OrderNo").Select

sebastienm

How do I switch between windows in the active workbook inside a M.
 
Hi,
To get the name of the book use
ActiveWorkbook.Name
so
Windows(ActiveWorkbook.Name & ":2").Activate
Also you can reference the active window by using ActiveWindow

I hope this helps,
Sebastien

"kdreyer" wrote:

How do I switch between windows in the active workbook inside a Macro.

I have a Macro that reformats how ever I need it to do that in Window 2 of
the active workbook. I cannot have it file specific. It needs to take the
active filename and drop it into the formula.

Here is what I have so far. This works but I cannot figure out how to get
the active filename.:

Windows("FS Side Vent.xls:2").Activate
Sheets("Print").Select
Range("OrderNo").Select
Cells.Select
Selection.EntireRow.Hidden = False
For I = 1 To 800
Range("A" & I).Select
If ActiveCell.Value = "0" Then
Selection.EntireRow.Hidden = True
Else
End If

Next I

Range("OrderNo").Select



All times are GMT +1. The time now is 11:04 PM.

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