Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variable in Excel Cell Address? 2

Status
Not open for further replies.

ChrisBurch

IS-IT--Management
Jul 3, 2001
184
AU
Hi all,

Is the a way of using a variable in a cell address?

Such as:-

Dim RowNum As Integer
RowNum = 3

Range("C&RowNum").select 'This doesn't work, but is intended to == C3

I've wriiten vba to sort a row of numbers, and I am trying to use RowNum to loop it through each row.
Thanks, Chris

It worked yesterday.
It doesn't work today.
That's Windows!
 
Hi,
Use the following method for referencing cells - works MUCH better than the Range("A1") method...
Code:
Cells(RowNbr, ColNbr).Select
or
Code:
Cells(RowNbr, ColNbr).Value = YourValue
Skip,
metzgsk@voughtaircraft.com
 
By the way, if you insist on using Range("A1") type notation, the way to accomplish this for your example is...
Code:
Range("C" & RowNum).select
Skip,
metzgsk@voughtaircraft.com
 
Thanks guys,

I went for Skip's suggestion. It is easier to handle. Chris

It worked yesterday.
It doesn't work today.
That's Windows!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top