Multiply a range by -1
Thanks for the help. So who is Gary? Anyhow, it works like a charm. OK, I
get that r is a range of cells, and that the loop goes through the range, but
how does Excel know how to treat rr? We are not telling it that rr is a
cell, or cell value, so how does it know what to do? I'm having a hard time
understanding the concept of what is going on. Usually, my code is riddled
with MsgBox(Variable), so I can "see" what is going on, but MsgBox(r) does
not work. MsgBox(rr) does work, so I can see that the sub is treating rr as
the cell value, but how did it know what to do?
"Gary''s Student" wrote:
Sub Inverter()
Dim r As Range, LastRow As Long, rr As Range
LastRow = 9
Set r = Range("E" & LastRow - 3 & ":I" & LastRow - 3)
For Each rr In r
rr.Value = -rr.Value
Next
End Sub
--
Gary''s Student - gsnu200907
"Greg Snidow" wrote:
Greetings everyone. I need to take all the values in a range, and make them
negative. I tried....
Range("E" & LastRow - 3 & ":I" & LastRow - 3) = _
Range("E" & LastRow - 3 & ":I" & LastRow - 3) * -1
I know I can put a -1 in a cell, then copy and paste special - multiply, but
I was looking for something the user will not see. Any ideas? Thank you.
Greg
|