Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search for a value in a column 1

Status
Not open for further replies.

acrosby

IS-IT--Management
Apr 22, 2003
2
US
Greetings,

I am trying to write some VBA code to read each cell in column A. If a negative value is found then the corresponding cell in column B will have a 0 in it.

I've tried writing code for this but have had no such luck!

Thanks much for all your help.
acrosby
 
Hi,

Here's an approch...
Code:
    With ActiveSheet.UsedRange
      For Each c In Range(Cells(.Row, 1), Cells(.Rows.Count + .Row - 1, 1))
         If c.Value < 0 Then c.Offset(0, 1).Value = 0
      Next
    End With
Hope this helps :)

Skip,
Skip@TheOfficeExperts.com
 
Thanks so much, Skip. That helped me out a lot!

~acrosby
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top