Condition Statement Help??
One way:
Public Sub NegateSELBook()
Dim rFound As Range
Dim sfoundAddr As String
With Columns(2)
Set rFound = .Find( _
What:="SEL Book", _
LookIn:=xlValues, _
LookAt:=xlWhole, _
MatchCase:=False)
If Not rFound Is Nothing Then
Do
sfoundAddr = rFound.Address
With rFound(1, 2)
.Value = -Abs(.Value)
End With
Set rFound = .FindNext(After:=rFound)
Loop Until rFound.Address = sfoundAddr
End If
End With
End Sub
Note: this will make the number always a negative number, as you
specified. If you'd rather have it just toggle between negative and
positive, change
.Value = -Abs(.Value)
to
.Value = -.Value
In article ,
CWit wrote:
Hello I'm familiar with other code but I'm trying to learn the lingo of
Excel/ VBA. I'm trying to write a condition statement that would allow
me to scan column B2 down and search for "SEL Book" if it finds those
words I would like it to change the corresponding number in Column C to
a negative number. Logically put it would look like this.
If B2 through B etc. = "SEL Book" then C etc. = negative number...
|