Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: getting cell value

  1. #1
    New Member
    Join Date
    Mar 2002
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi, Im a new to writing excel macros and Im running into a problem that I'm sure has an easy solution. I would like to get the value of a cell, (.Cells.Value(2,2)) and store it into a variable within my module. x=.Cells.Value(2,2) However, I need the variable to be an integer or number, not a string or variant. This is so that I can take the value from the cell and manipulate it as a number. (i.e., x = x + 1)If anyone could give me a little guidance on this, I would be most appreciative. Thanks.

  2. #2
    MrExcel MVP Al Chara's Avatar
    Join Date
    Feb 2002
    Location
    Newark, Delaware
    Posts
    1,701
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Try the following code:

    Dim x As Integer
    x = Cells(2, 2).Value
    x = x + 1
    Best regards,
    Allan Chara
    http://www.mrspreadsheets.com

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi
    Just a little addition to Al Chara.
    I do not know what your number is, but assigning a variable dimmed as an integer will only accept whole numbers from -32,768 to 32,767.
    If you run into any problems, search for Data Types in VBA help.
    Have a Nice Day!
    Tom

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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