Solved

Loop down and make minus

Posted on 2011-09-29
4
140 Views
Last Modified: 2012-05-12
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
0
Comment
Question by:Seamus2626
  • 2
  • 2
4 Comments
 
LVL 24

Expert Comment

by:StephenJR
ID: 36814805
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
 

Author Comment

by:Seamus2626
ID: 36814829
Looks good Stephen, how can i set sheet1 = to the tab name (Raw Data)
0
 
LVL 24

Accepted Solution

by:
StephenJR earned 500 total points
ID: 36814854
Change line 5 to

With Sheets("Raw Data").Columns(10)
0
 

Author Closing Comment

by:Seamus2626
ID: 36814916
Cheers Stephen!
Seamus
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now