View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
GBExcel via OfficeKB.com GBExcel via OfficeKB.com is offline
external usenet poster
 
Posts: 26
Default Loop Until non-incrementing cell condition met.

Hi,

I am a VBA dummy. I am stuck on the following:

I have a cell GJ1 that will either have a 1 or a 0 value. My routine needs to
loop until GJ1 changes from 0 to 1. The solutions that I have seen on the
Internet use counters to count loops until a condition is met. In my case,
counters or incrementing is not applicable since the condition that
determines if GJ1 is 1 is not based on counters or incrementing but on user
input. The example below is what I am trying. I can get the loop to work,
but then it just keeps looping infinitely.

Sub PasteValuesTill()

' The code below must loop until cell GJ1=1. GJ1 can only have values of 0 or
1.
'
Sheets("ThisSheet").Select
Range("E5:G5").Select
Selection.Copy
Range("F2:G2").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Do Until GJ1 = 1
Loop

End Sub

--
Message posted via http://www.officekb.com