stephicohu
New Member
- Joined
- Jan 27, 2023
- Messages
- 26
- Office Version
- 365
- Platform
- MacOS
I hope the title makes sense. As I have stated, I am a self learner, with about 3 weeks of experience. I am having problems in using a cell location as a variable. I know you have to use a string expression but what I want to do is to convert a numeric number into a column cell location. For example if I have AG3 how do I convert this from an integer to a string expression. I need to know because I am using AH3 as the next expression getting a formula.
This is an example of the code I am doing:
Dim col1 As Integer
Dim cellnum As Integer
Dim col2 As Integer
Dim cellstr As String
cellnum = 33
cellstr = CStr(cells(33,3))
col1 = -15
col2 = -10
Sheets("January").Activate
Range(cellstr).Select
ActiveCell.FormulaR1C1 = "=SUM(RC[" & CStr(col1) & "]:RC[" & CStr(col2) & "])"
The trouble is converting the "AG3" from an integer value to this value.
I have tried many things but they failed. The best attempt I thought of was using the above value but it failed. I get a error on debug stating global error. I would appreciate anyones help in this matter.
Thanks....
Stephanie.....
This is an example of the code I am doing:
Dim col1 As Integer
Dim cellnum As Integer
Dim col2 As Integer
Dim cellstr As String
cellnum = 33
cellstr = CStr(cells(33,3))
col1 = -15
col2 = -10
Sheets("January").Activate
Range(cellstr).Select
ActiveCell.FormulaR1C1 = "=SUM(RC[" & CStr(col1) & "]:RC[" & CStr(col2) & "])"
The trouble is converting the "AG3" from an integer value to this value.
I have tried many things but they failed. The best attempt I thought of was using the above value but it failed. I get a error on debug stating global error. I would appreciate anyones help in this matter.
Thanks....
Stephanie.....