Passing the Value of a Cell to a VBA variable.

R

RMS

Is it possible to pass the contents of an Excel worksheet Cell to a VBA
variable for further processing? Thanks.
 
T

TomPl

dim vrtMyVariable as variant

vrtMyVariable = activecell.value

This will assign the value of the active cell to the variable named
vrtMyVariable
 
B

Bob Bridges

Heck, yeah; it's practically the one fundamental necessity! If we couldn't
do even that, there wouldn't be much point in writing Excel programs at all.

TomPl was right as far as he went: ActiveCell.Value will get you the
contents of the cell that is currently selected. I just wanted to go a bit
further: Your program doesn't have to be limited to the active cell, but can
also get the contents of "A4", of the cell in row 23 column 5, of the cell at
row x1+3, column x2*2, of the top left cell in the selected range, of the
next cell that contains the string "000", pretty much anything you can think
of. It can get the text value, the formula, the font size, the column width,
its protection status...again, pretty much anything you can do in Excel you
can control from VBA/Excel.

Pardon my enthusiasm; you're just asking too small, that's all. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top