Locate negative number

B

BurtArkin

I have a column of numbers (based on an underlying formula), starting
positive at the top. Somewhere in the column, a number becomes negative.
How, using VB code, do I search for that cell, where the number =<0. Once
the cell is located, I want to then alter the formula of the cell to its
left. I would appreciate any help I get. Thanks
 
M

Mike H

Hi,

You didn't say what you wanted the formula altered to so this simply enter
123 in the appropriate cell

Sub ordinate()
Set myrange = Range("B1:B" & Cells(Rows.Count, "B").End(xlUp).Row)
For Each c In myrange
If c.Value <> "" And c.Value <= 0 Then
c.Offset(0, -1).Value = 123 ' Do what you want
Exit Sub
End If
Next


Mike
 
B

BurtArkin

Thank you so much for your quick response. I will play with it, and, if
there are any problems (I'm not too swift!), I'll get back to you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top