![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 3
|
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 |
|
MrExcel MVP
Join Date: Feb 2002
Location: Monterrey, Mexico
Posts: 1,433
|
Try the following code:
Dim x As Integer x = Cells(2, 2).Value x = x + 1
__________________
Kind regards, Al Chara |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Mar 2002
Location: Cincinnati, Ohio, USA
Posts: 6,824
|
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 |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|