Help with Loop

  • Thread starter Thread starter JMay
  • Start date Start date
J

JMay

All cells in Column C are being filled with "LOW";
How do I fix it so that only 0's in Column B paste "LOW" in Column C,
TIA,

Sub TryAgain()
Dim myCell As Range, rng As Range
Set rng = Range("B1:B10")
For Each myCell In rng
If myCell = 0 Then
rng.Offset(, 1).Value = "LOW"
End If
Next myCell
End Sub
 
Sub TryAgain()
Dim myCell As Range, rng As Range
Set rng = Range("B1:B10")
For Each myCell In rng
If myCell = 0 and not isempty(mycell) Then '<==
myCell.Offset(0, 1).Value = "LOW" '<===
End If
Next myCell
End Sub
 
JMay,

not tersted, but hope okay

Sub TryAgain()
Dim myCell As Range, rng As Range
Set rng = Range("B1:B10")
For Each myCell In rng
If myCell.Value = 0 And myCell.Value <> "" Then
myCell.Offset(, 1).Value = "LOW"
End If
Next myCell
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)
 
Sub TryAgain()

Dim myCell As Range, rng As Range

Set rng = Range("B1:B10")

For Each myCell In rng
If myCell = 0 and not isempty(mycell) Then
myCell.Offset(0, 1).Value = "LOW"
Else: myCell.Offset(0, 1).Value = "" '<==
End If
Next myCell

End Sub

Added a line to delete any "LOW" texts that are already there whe
script is started
 
Thanks guys, for your help
I better understand what I was not doing (right)..
 

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

Back
Top