PDA

View Full Version : What is the mistake in this code ..



Nader
01-07-2008, 05:07 PM
What is the mistake in this code
I want toprint the number beside the letter in the range property as it show in the code.

Dim s As Integer
Dim n As Integer
s = textbox1.Text 'only number
n = textbox2.Text 'only number
Range("As:dn").Select

tpoynton
01-07-2008, 06:47 PM
what's it for? your questions seem like homework.

malik641
01-07-2008, 06:50 PM
The main problem is that VBA sees "s" and "n" as actual text, making it think "Ok, let's select columns AS to DN".

One method you could use is to break up your string a little:
Range("A" & s & ":D" & n).Select

Another way is to use the Cells() property:
Range(Cells(s,"A"), Cells(n,"D")).Select

Hope this helps!