ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to change macro or module level const that is calculated (https://www.excelbanter.com/excel-programming/401855-macro-change-macro-module-level-const-calculated.html)

Ren

Macro to change macro or module level const that is calculated
 
Is it possible to use a macro to change another macro.

I have two Module level constant that i use

Const numCol As Integer = 19
Const numWS As Integer = 3

Ideally, these number can change automatically. It won't work if i delcare a
const with something such as Const numWS As Integer =
Application.WorksheetFunction.CountA(Worksheets("S heet1").Range("G:G"))

How can I make this work? I am thinking that maybe calling a macro in
another module can change this.

Steven


Per Jessen[_2_]

Macro to change macro or module level const that is calculated
 
On 28 Nov., 19:59, Ren wrote:
Is it possible to use a macro to change another macro.

I have two Module level constant that i use

Const numCol As Integer = 19
Const numWS As Integer = 3

Ideally, these number can change automatically. It won't work if i delcare a
const with something such as Const numWS As Integer =
Application.WorksheetFunction.CountA(Worksheets("S heet1").Range("G:G"))

How can I make this work? I am thinking that maybe calling a macro in
another module can change this.

Steven


Hi Steven

You can not change a constant, so you have to declare a variable.

I donīt know what you want to achive, but maybe you can use an event.

Dim numCol as Integer

Private Sub Worksheet_Change(ByVal Target As Range)
numCol =
Application.WorksheetFunction.CountA(Worksheets("S heet1").Range("G:G"))
'Rest of the code

End Sub


Regards,

Per


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

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