Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default Help with Loop

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help with Loop

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

--
Regards,
Tom Ogilvy

"JMay" wrote in message news:OyWzc.382$WI2.162@lakeread05...
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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Help with Loop

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)

"JMay" wrote in message news:OyWzc.382$WI2.162@lakeread05...
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




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with Loop

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

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default Help with Loop

Thanks guys, for your help
I better understand what I was not doing (right)..


"Berend Botje " wrote in
message ...
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 when
script is started.


---
Message posted from http://www.ExcelForum.com/



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop Christina Excel Discussion (Misc queries) 6 March 23rd 10 12:04 AM
Do loop Christina Excel Discussion (Misc queries) 0 March 18th 10 03:19 PM
Find loop doesn't loop JSnow Excel Discussion (Misc queries) 2 June 24th 09 08:28 PM
Worksheet_Change - loop within a loop bgm Excel Programming 1 January 19th 04 01:27 PM
HELP!!!! Can't stop a loop (NOT an infinite loop) TBA[_2_] Excel Programming 3 December 14th 03 03:33 PM


All times are GMT +1. The time now is 03:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"