ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to indicate that the current visible worksheet is the active o (https://www.excelbanter.com/excel-programming/353631-how-indicate-current-visible-worksheet-active-o.html)

George Furnell[_2_]

How to indicate that the current visible worksheet is the active o
 
Good day,

I have a function in a module, in which I would like to state that the
current visible worksheet should be treated as the active one, because I do
not know during execution what the sheet name will be. In the example below
the sheet name is hardcoded, what is the better solution?

With ActiveWorkbook
With .Worksheets("Titans")
.Range("M5").Value = 5
End With
End With

Kind regards

George




Norman Jones

How to indicate that the current visible worksheet is the active o
 
Hi George,

Dim SH As Worksheet

Set SH = ActiveSheet

SH.range("M5").Value = 5

The object variable SH will refer to the stipulated sheet, irrespective of
whether it is subsequently active or not..


---
Regards,
Norman


"George Furnell" wrote in message
...
Good day,

I have a function in a module, in which I would like to state that the
current visible worksheet should be treated as the active one, because I
do
not know during execution what the sheet name will be. In the example
below
the sheet name is hardcoded, what is the better solution?

With ActiveWorkbook
With .Worksheets("Titans")
.Range("M5").Value = 5
End With
End With

Kind regards

George







All times are GMT +1. The time now is 03:59 PM.

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