Loop down and make minus

Hi,

I am looking for some vba code to loop down Column J, and if it finds the word "Sel" then multiply the adjacent cell in Column O by -1

Has anyone anything for that?

Thanks
Seamus
Seamus2626Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
StephenJRConnect With a Mentor Commented:
Change line 5 to

With Sheets("Raw Data").Columns(10)
0
 
StephenJRCommented:
Seamus - try this:
Sub x()
  
Dim rFind As Range, sAddr As String
 
With Sheet1.Columns(10)
    Set rFind = .Find(What:="Sel", LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
    If Not rFind Is Nothing Then
        sAddr = rFind.Address
        Do
            rFind.Offset(, 5) = -1 * rFind.Offset(, 5)
            Set rFind = .FindNext(rFind)
         Loop While rFind.Address <> sAddr
    End If
End With
     
End Sub

Open in new window

0
 
Seamus2626Author Commented:
Looks good Stephen, how can i set sheet1 = to the tab name (Raw Data)
0
 
Seamus2626Author Commented:
Cheers Stephen!
Seamus
0
All Courses

From novice to tech pro — start learning today.