Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I don't understand why this code works:
Private Sub one_Click() For i = 27 To 999 Cells(i, i).Value = i If Cells(i, 1).Value = "More" Then Cells(i, 1).Value = Sheets("Prices").Range("A3") Cells(i, 3).Value = Sheets("Prices").Range("B3") Cells(i, 4).Value = Sheets("Prices").Range("C3") Exit For End If Next i End Sub But this code does not: Private Sub CommandButton6_Click() For i = 31 To 999 Cells(i, i).Value = i <<<<<<HERE IS WHERE IT STOPS If Cells(i, 2).Value = "Fruit" Then Range("AD12").Select Application.CutCopyMode = False Selection.Copy Range ("i, 2"). Select Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _ :=False, Transpose:=False Exit For End If Next i Range("AA1:AD10").Select Application.CutCopyMode = False Selection.ClearContents Range("B30").Select End Sub What is confusing is the same line of code works in the fist example but does not in the second. Any help is most welcome. In the second example I am searching for a certain value in the next row with value FRUIT in col B, when I find that cell, copy the value of another cell into that cell, clear a certain range so I can begin again. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Advancing outer Loop Based on criteria of inner loop | Excel Programming | |||
Loop Function unable to loop | Excel Programming | |||
Problem adding charts using Do-Loop Until loop | Excel Programming | |||
Worksheet_Change - loop within a loop | Excel Programming | |||
HELP!!!! Can't stop a loop (NOT an infinite loop) | Excel Programming |