Link to home
Start Free TrialLog in
Avatar of slattbr
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.
SOLUTION
Avatar of SNilsson
SNilsson
Flag of Sweden image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
slight mod

sMyRange = "G" & Cstr(iRange1) & ":G" & Cstr(iRange2)

~b
must convert your ints to strings
Avatar of slattbr
slattbr

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.