cell values copied!!

  • Thread starter Thread starter aapp81
  • Start date Start date
A

aapp81

i have 2 columns - W and F
i need some type of macro that if a cell in W is greater than ">"
cell in F, then F's value will automatically appear in W.

example:

w2 is 40
f2 is 30

therefore w2 should become 40

the W column is already filled and i'm filling in F cell by cell fro
outside info.

also, the cells are compared to their "rows" only meaning w2 = f2 an
so on, not w2 = f5, etc...

the macro doesn't have to loop as i type in column f... meaning i'll b
very happy w/ a macro that i can just run once when i feel like it an
it'll just take care of the 2 columns for me. but either will do...

thanks
 
What you wrote and what you said in your example aren't
quite the same, but I think I am reading your question
correctly. If W is greater than F, put the value of F
into W?

If you use the IF command in column W, it will be quite
easy.

Your formula will look like:

=IF(W2>F2,F2,W2)

This formula says that if W2 is greater than F2, Excel
will put the value of F2 into cell W2. Otherwise, it
will keep the original value of W2 in the cell.
 
for i = 1 to range.[w65536].End(xlUp).Row step 1
if range("w" & i ).value > range("f" & i).value then
range("f" & i).value = range("w" & i).value
end if
next i



' range.[w65536].End(xlUp).Row gets last row in column W that has a
entr
 
Sub UpdateW()
for each cell in Range(cells(1,"W"),Cells(rows.count,"W").End(xlup))
if cells(cell.row,"F").Value < cell.Value then _
cell.Value = cells(cell.row,"F").Value
Next
End Sub
 
Sub UpdateW()
for each cell in Range(cells(1,"W"),Cells(rows.count,"W").End(xlup))
if not isempty(cells(cell.row,"F")) then
if cells(cell.row,"F").Value < cell.Value then _
cell.Value = cells(cell.row,"F").Value
End If
Next
End Sub

Probably should check to make sure F has a value.

--
Regards,
Tom Ogilvy


Tom Ogilvy said:
Sub UpdateW()
for each cell in Range(cells(1,"W"),Cells(rows.count,"W").End(xlup))
if cells(cell.row,"F").Value < cell.Value then _
cell.Value = cells(cell.row,"F").Value
Next
End Sub
 
are you suggesting intentional circular references or you just don't know?
If you enter a formula in W, how does W get a value to start with?
 
if you are talking about mudraker's code

you said:
need some type of macro that if a cell in W is greater than ">" a
cell in F, then F's value will automatically appear in W.

As written, W's value appears in F.
 
Back
Top