slattbr
asked on
Reference Cell Range with Counter
I am populating an excel spreadsheet through automation in access. I am running into a problem when I try to reference multiple cells using a counter.
Ex: I want to merge the last 2 rows in column G, and the Counter = 15
XlExcel.Range("G & Counter + 1:G" & Counter +2).Merge
I know that this works if you know what one of the cells would be such as
XlExcel.Range("G16:G" & Counter + 2).Merge
However, this will not work for my application.
I have tried variations of the above and have not gotten it to work yet. Does anyone know what I am doing wrong? Any help is appreciated.
Ex: I want to merge the last 2 rows in column G, and the Counter = 15
XlExcel.Range("G & Counter + 1:G" & Counter +2).Merge
I know that this works if you know what one of the cells would be such as
XlExcel.Range("G16:G" & Counter + 2).Merge
However, this will not work for my application.
I have tried variations of the above and have not gotten it to work yet. Does anyone know what I am doing wrong? Any help is appreciated.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
must convert your ints to strings
ASKER
works, thanks
No not really, it works as in my first example, integers can be concatanated with strings without a problem, the other way around on the other hand is a problem.
sMyRange = "G" & Cstr(iRange1) & ":G" & Cstr(iRange2)
~b