Does variable set to cell value automatically becomre cell value?

S

salgud

I think I know the answer to this, but I want to be sure. I'm incrementing
a value that is in a cell location describe in part by a variable. The
formula looks like:

ws.Cells(iMoRow, "T").Value = _
ws.Cells(iMoRow, "T").Value + iOVComplCON

So the value in the cell is incremented by the variable "iOVComplCON"
amount. No problem.

Is this the same thing?

iWt = Cells(iMoRow, "T").Value
iWT = Cells(iMoRow, "T").Value + iOVComplCON

or do I have to have another line added to the two above:
Cells(iMoRow, "T").Value = iWt

I'm pretty sure that I have to have the added line, which means it's a
little simpler not to have the variable iWt at all, isn't it? Is there a
better/shorter way to do the same thing?

Thanks!
 
P

p45cal

Responses in quted text below:

salgud;583629 said:
I think I know the answer to this, but I want to be sure. I'm
incrementing
a value that is in a cell location describe in part by a variable. The
formula looks like:

ws.Cells(iMoRow, "T").Value = _
ws.Cells(iMoRow, "T").Value + iOVComplCON

So the value in the cell is incremented by the variable "iOVComplCON"
amount. No problem.

Is this the same thing?

iWt = Cells(iMoRow, "T").Value
iWT = Cells(iMoRow, "T").Value + iOVComplCON
NO


or do I have to have another line added to the two above:
Cells(iMoRow, "T").Value = iWt
*Yes*
I'm pretty sure that I have to have the added line, which means it's a
little simpler not to have the variable iWt at all, isn't it?
*Yes*
Is there a
better/shorter way to do the same thing?
Only if you're referring to that cell in a lot of
places in the code it might be worth adding a line before any of those
places (usually straight after the value of iMoRow is changed) like: Code:
-------------------- Code:
--------------------
not a lot shorter unless you choose to use a shorter variable name
like 'MC' instead of 'myCell'

Thanks!
 
P

p45cal

salgud;584130 said:
Thanks for clarifying that.

I forgot to suggest:

Code:
--------------------
with ws.Cells(iMoRow, "T")
...
...
.Value = .Value + iOVComplCON
End with
 
S

salgud

I forgot to suggest:

Code:
--------------------
with ws.Cells(iMoRow, "T")
...
...
.Value = .Value + iOVComplCON
End with

--------------------

Should have thought of that myself. Thanks again.
 

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