omnisautnihil
New Member
- Joined
- May 13, 2011
- Messages
- 19
Hello, I am just now beginning to learn how to write Macros and I have been working on one that is being used to search through one document for a value in another and labeling an adjacent cell with the counter. All of my research points to people who do not have EndIf used appropriately but I do not see how mine is similar. Can anyone see why my code won't compile with "Loop with no Do" error?
*****************************
Sub Sorting()
Windows("File1.xls").Activate
Dim Count As Integer
Count = -1
Dim gCount As Integer
gCount = 0
Dim ICount As Integer
ICount = Count - gCount
Range("D5").Select
Dim rFound As Range
Do Until Selection.Value = ""
Loop
MsgBox ("DONE!")
End Sub
**************************************************
If something needs explanation just let me know, but I'm only looking for why it does not understand my Loop statements where I want to break inside the if statements.
*****************************
Sub Sorting()
Windows("File1.xls").Activate
Dim Count As Integer
Count = -1
Dim gCount As Integer
gCount = 0
Dim ICount As Integer
ICount = Count - gCount
Range("D5").Select
Dim rFound As Range
Do Until Selection.Value = ""
Count = Count + 1
Range("D5").Offset(Count, 0).Select
If Selection.Value = "General" Then
Range("D5").Offset(Count, 0).Select
If Selection.Value = "General" Then
gCount = gCount + 1
Loop
ElseIf Selection.Value = Selection.Value.Offset(-1, 0) ThenLoop
Loop
Else
Selection.Value.Copy
Windows("ReviewAide.xls").Activate
Set rFound = Columns(2).Find(What:=Selection.Value, After:=Range ("B832"), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows,_ SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
Windows("ReviewAide.xls").Activate
Set rFound = Columns(2).Find(What:=Selection.Value, After:=Range ("B832"), LookIn:=xlValues, LookAt:=xlPart, SearchOrder:=xlByRows,_ SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
If Not rFound Is Nothing Then
End IfSelection.Offest(0, -1).Select = "Issue " & ICount
ActiveCell.FontStyle = "Bold"
Windows("File1.xls").Activate
ElseActiveCell.FontStyle = "Bold"
Windows("File1.xls").Activate
MsgBox (Selection.Value & "is not a valid ID.")
Exit Do
End IfExit Do
MsgBox ("DONE!")
End Sub
**************************************************
If something needs explanation just let me know, but I'm only looking for why it does not understand my Loop statements where I want to break inside the if statements.