I'm trying to use this as a Public or Global variable
I did this:
Insert -> Module:
Result:
Run time error 1004: Application defined or object defined error at this line in my VBA code
Can anyone tell me what's wrong ? Seems simple enough to declare a Global variable only once in one place only. I keep copying
in VBA code in buttons on12 different Userforms. Having to change each one to a new colnum value at EOY is a real pain.
Thanks for anyone's help.
cr
Code:
colnum = Round((Date - DateValue("12/20/2017")) / 7, 0)
Insert -> Module:
Code:
Public colnum As Integer
Function UpdateCorrectColumn() As Integer
colnum = Round((Date - DateValue("12/20/2017")) / 7, 0)
End Function
Run time error 1004: Application defined or object defined error at this line in my VBA code
Code:
Dim r As Range
Case Is = "Food"
Set r = Sheets("Budget").Cells(16, colnum) <----bugs out here highlighted yellow
Can anyone tell me what's wrong ? Seems simple enough to declare a Global variable only once in one place only. I keep copying
Code:
colnum = Round((Date - DateValue("12/20/2017")) / 7, 0)
Thanks for anyone's help.
cr