Results 1 to 6 of 6

Thread: [RESOLVED] Range question, robdog maybe you can help

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    48

    [RESOLVED] Range question, robdog maybe you can help

    I have another syntax question for you... and thanks by the way for helping me the other day, the program is working excellent! Anyway, to my new question.

    Cell A1 contains the integer 5
    Cell A2 contains the integer 9

    Then I have in a module:

    sub store_number()

    Dim number as Integer

    number = 500
    Sheets("sheet1").Range("A1,A2").Value = number

    end sub

    Basically I'm trying to store the value of number in cell [A1,A2], but can't get the syntax and i've been trying to figure this out for about 30mins, and I have no book to help me out.


    PS. heres a link to what I was working on, it's in a zip. Load the .xll file as one of your addins then open the acceldevel.xls. Hope ya like it.

    http://stillwaterit.com/stuff.zip
    Last edited by kleen00; Feb 9th, 2006 at 09:28 PM.

  2. #2
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Range question, robdog maybe you can help

    Change
    VB Code:
    1. Sheets("sheet1").Range("A1,A2").Value = number
    to
    VB Code:
    1. Sheets("sheet1").Range("A1:A2").Value = number

    I.e. change the comma to a colon.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    48

    Re: Range question, robdog maybe you can help

    Cool. Thanks DKenny.

    Ok one more. =)
    -----

    number = 500

    row = Sheets("pre").Range("A1").Value
    col = Sheets("pre").Range("B1").Value

    Sheets("sheet1").Range("[col,row]").Value = number

    -----

    So now row = A1 = 5 and col = B1 = 9, and I want to store 'number' in col 5, row 9. How do I do that?

  4. #4
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Range question, robdog maybe you can help

    VB Code:
    1. Sheets("sheet1").Cells(Row, col).Value = Number
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2006
    Posts
    48

    Re: Range question, robdog maybe you can help

    wow that was simple. Thanks again!!!!

  6. #6
    Frenzied Member DKenny's Avatar
    Join Date
    Sep 2005
    Location
    on the good ship oblivion..
    Posts
    1,171

    Re: Range question, robdog maybe you can help

    No worries.
    Don't forget to mark this thread as complete - if your issue is resolved.
    Declan

    Don't forget to mark your Thread as resolved.
    Take a moment to rate posts that you think are helpful

Posting Permissions

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



Click Here to Expand Forum to Full Width