Solved

Reference Cell Range with Counter

Posted on 2004-08-10
6
312 Views
Last Modified: 2010-04-17
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.
0
Comment
Question by:slattbr
6 Comments
 
LVL 8

Assisted Solution

by:SNilsson
SNilsson earned 125 total points
ID: 11764094

Something like this maybe ?

iRange1 = Counter + 1
iRange2 = Counter + 2

sMyRange = "G" & iRange1 & ":G" & iRange2
 
XlExcel.Range(sMyRange).Merge
0
 
LVL 3

Accepted Solution

by:
Eduski earned 125 total points
ID: 11764140
XlExcel.Range("G & Counter + 1:G" & Counter +2).Merge

should be

XlExcel.Range("G" & Counter + 1 & ":G" & Counter +2).Merge
0
 
LVL 8

Expert Comment

by:bramsquad
ID: 11764146
slight mod

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

~b
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 8

Expert Comment

by:bramsquad
ID: 11764155
must convert your ints to strings
0
 

Author Comment

by:slattbr
ID: 11764224
works, thanks
0
 
LVL 8

Expert Comment

by:SNilsson
ID: 11764245

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.
0

Featured Post

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How to split this in C++ 4 102
Please explain: Aspect Oriented Programming 2 93
Basic Java Case or If-Else statement... 3 50
Advice on Xojo as a development tool over VB. 4 55
Here we come across an interesting topic of coding guidelines while designing automation test scripts. The scope of this article will not be limited to QTP but to an overall extent of using VB Scripting for automation projects. Introduction Now…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question