Consulting

Results 1 to 3 of 3

Thread: What is the mistake in this code ..

  1. #1

    What is the mistake in this code ..

    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.
    [VBA]
    Dim s As Integer
    Dim n As Integer
    s = textbox1.Text 'only number
    n = textbox2.Text 'only number
    Range("As:dn").Select
    [/VBA]

  2. #2
    VBAX Mentor tpoynton's Avatar
    Joined
    Feb 2005
    Location
    Clinton, MA
    Posts
    399
    Location
    what's it for? your questions seem like homework.

  3. #3
    Administrator
    2nd VP-Knowledge Base
    VBAX Master malik641's Avatar
    Joined
    Jul 2005
    Location
    Florida baby!
    Posts
    1,533
    Location
    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:
    [VBA]Range("A" & s & "" & n).Select[/VBA]

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

    Hope this helps!




    New to the forum? Check out our Introductions section to get to know some of the members here. Feel free to tell us a little about yourself as well.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •