Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Does variable set to cell value automatically becomre cell value?

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!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Does variable set to cell value automatically becomre cell value?


Responses in quted text below:

salgud;583629 Wrote:
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:
--------------------
Set myCell = Cells(iMoRow, "T")

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

then use:

Code:
--------------------
myCell.value = myCell.value + iOVComplCON

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

not a lot shorter unless you choose to use a shorter variable name
like 'MC' instead of 'myCell'

Thanks!



--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: 558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=161549

Microsoft Office Help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 219
Default Does variable set to cell value automatically becomre cell value?

On Thu, 10 Dec 2009 23:43:59 +0000, p45cal wrote:

Responses in quted text below:

salgud;583629 Wrote:
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:
--------------------
Set myCell = Cells(iMoRow, "T")

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

then use:

Code:
--------------------
myCell.value = myCell.value + iOVComplCON

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

not a lot shorter unless you choose to use a shorter variable name
like 'MC' instead of 'myCell'

Thanks!


Thanks for clarifying that.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Does variable set to cell value automatically becomre cell value?


salgud;584130 Wrote:
On Thu, 10 Dec 2009 23:43:59 +0000, p45cal wrote:

Responses in quted text below:

salgud;583629 Wrote:
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:
--------------------
Set myCell = Cells(iMoRow, "T")

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

then use:

Code:
--------------------
myCell.value = myCell.value + iOVComplCON

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

not a lot shorter unless you choose to use a shorter variable name
like 'MC' instead of 'myCell'

Thanks!


Thanks for clarifying that.


I forgot to suggest:

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

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


--
p45cal

*p45cal*
------------------------------------------------------------------------
p45cal's Profile: 558
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=161549

Microsoft Office Help

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If cell is blank automatically enter today's date in the same cell LCTECH001 Excel Discussion (Misc queries) 22 April 5th 23 02:50 PM
how to cut part of a text from one cell and automatically paste itonto another cell Sonja[_2_] Excel Discussion (Misc queries) 6 August 17th 09 11:35 PM
Automatically change cell colors based on date in cell Greg Excel Discussion (Misc queries) 2 January 27th 09 05:55 PM
If data added to Excel cell it automatically make's another cell equal zero [email protected] Excel Programming 1 October 19th 05 06:00 PM
How to copy formatting when moving from cell to variable to another cell on another worksheet kls[_2_] Excel Programming 1 September 11th 04 10:42 PM


All times are GMT +1. The time now is 10:49 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"