how do I set a variable equal to the value of a cell?

  • Thread starter Thread starter June Macleod
  • Start date Start date
J

June Macleod

In vba how do I set a variable equal to the contents of a cell?

I tried:

dim asstype%
dim therow%
therow = 2
asstype = Worksheets("Sheet1").Range(Cells(therow, 21), Cells(therow,
21)).Value

but I get an "application defined or object defined error".

The problem seems to be in the Worksheets("Sheet1") part as the rest of the
line happy returns a value.

I am trying to run a macro on a cell in sheet2 that finds some values on
sheet 1 before performing a calculation.

Help!

June
 
Hi June
try the following:
dim asstype
dim therow as long
therow = 2
asstype = Worksheets("Sheet1").Cells(therow, 21).Value
 
Thank you.

That worked well.

June


Frank Kabel said:
Hi June
try the following:
dim asstype
dim therow as long
therow = 2
asstype = Worksheets("Sheet1").Cells(therow, 21).Value
 

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

Back
Top