Range with computed column number

F

Fred Holmes

Range(A5000) is a valid VBA expression.

How do I specify "A" as a variable?

Range(Columns(n)5000) or something like that?

Where n is an integer column number obtained separately.

The above trial expression returns an error message:

Expected separator or ")" .

But the trial expression has balanced parenthses.

Thanks,

Fred Holmes
 
F

FSt1

hi
not sure exactly what you are after but is this close????
Sub FredHolmes()
Dim c As String
c = InputBox("enter column letter")
'or
'c = "A"
Range(c & "10").Select
End Sub

hope i guessed good
regards
FSt1
 
F

FSt1

hi
afterthought.
vb's error messages are not fool proof. vb is real picky about syntax and at
times will throw up odd error messages based on what it runs into. the
general catch all error in 1004 application or object defined error. meaning
something's wrong but i don't know what. i think your's is a syntax problem
where vb doesn't recognize the word column as you have it written. i'm
guessing.

Regards
FSt1
 
I

IanKR

How do I specify "A" as a variable?
Range(Columns(n)5000) or something like that?

Where n is an integer column number obtained separately.

Range(Cells(5000,n))

You may need to fully-reference Rang and/or Cells.
 
F

Fred Holmes

No, unforturnately. The column designator has to be a number, because
it is computed from other variables using math.

Fred Holmes
 
F

Fred Holmes

Many thanks. Great lead!

Actually,

Cells(5000, n)

is the expression I'm looking for.

Fred Holmes
 
Top