stephicohu
New Member
- Joined
- Jan 27, 2023
- Messages
- 32
- Office Version
- 365
- Platform
- MacOS
Hi!
I have been self-teaching myself VBA Excel and been doing this for about a month. I have been enjoying the learning experience. I do have several questions that has been bothering me. I am wanting to put a variable in the Range function so I can change the value intermittently. This is an example of my work:
Absolute Macro
'
'
Dim Num As String
Num = "AG5"
Range(" & Num &").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-31]:RC[-25])"
Range("AH5").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=AVERAGE(RC[-32]:RC[-26])"
Range("AH6").Select
I have tried the following options and they didn't work:
Range("Num")
Range (Num)
the error message I get is this:
Run-time error '1004':
Method 'Range' of 'object '_Global' failed.
I do have two questions to ask:
1) what am I doing wrong?
2) what does the run-time error means?
Thanks for your help in this matter. I believe it might be a simple thing but I haven't been able to find the answer yet. Oh yeah, I am running VBA Excel on MacOS.......
I have been self-teaching myself VBA Excel and been doing this for about a month. I have been enjoying the learning experience. I do have several questions that has been bothering me. I am wanting to put a variable in the Range function so I can change the value intermittently. This is an example of my work:
Absolute Macro
'
'
Dim Num As String
Num = "AG5"
Range(" & Num &").Select
ActiveCell.FormulaR1C1 = "=SUM(RC[-31]:RC[-25])"
Range("AH5").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=AVERAGE(RC[-32]:RC[-26])"
Range("AH6").Select
I have tried the following options and they didn't work:
Range("Num")
Range (Num)
the error message I get is this:
Run-time error '1004':
Method 'Range' of 'object '_Global' failed.
I do have two questions to ask:
1) what am I doing wrong?
2) what does the run-time error means?
Thanks for your help in this matter. I believe it might be a simple thing but I haven't been able to find the answer yet. Oh yeah, I am running VBA Excel on MacOS.......