Thread: stuck at a loop
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
computers hate me computers hate me is offline
external usenet poster
 
Posts: 22
Default stuck at a loop

ok i dont know what im doing wrong

I put the macro in and pressed run and NOTHING not an error message. Just
nothing happend. Do i need to be at a certain cell before i begin the macro
or what could it be?

"Joel" wrote:

Her is code that I just tested

Sub IdentNewAlarm()

Set StartCell = ActiveCell

'Find Last Row in column B
With Sheets("BF4 AlarmsCells")
LastRow = .Range("B" & Rows.Count).End(xlUp).Row
NewRow = LastRow + 1
End With

With Sheets("Data 14")
RowCount = 1
Do While .Cells(RowCount, "N").Value < ""
ID = .Cells(RowCount, "N").Value
With Sheets("BF4 AlarmsCells")
Set c = .Columns("A").Find(what:=ID, _
LookIn:=xlValues, _
lookat:=xlWhole)
If c Is Nothing Then
.Cells(NewRow, "D").Value = _
Sheets("Data 14").Cells(RowCount, "N")

NewRow = NewRow + 1
End If
End With
RowCount = RowCount + 1
Loop
End With

End Sub


"computers hate me" wrote:

Ok so i wrote a macro that compares a list of alarms from sheet 1 on column
d and compares it to a list of "master alarms" in sheet 2 in column a.

If there an alarm found in the first sheet comlumn d but its not in the
"master alarms" then it pasts this alarm at the end of the "master alarms"
list.

But my macro seems to get stuck in sheet 1 cell( D9). it just keeps coping
the same cell over and over again to the end of my "master alarms" and it
never stops i dont knwo why
here is the macro

Public row1, row2 As Integer
Public row3 As Integer
Public alarm1, alarm2 As String




Sub Alarms()

row1 = 8
row2 = 1
row3 = 1

Do Until Sheets("Data 14").Cells(row1, 4) = ""

Do Until Sheets("Identified Bf 14 alarms").Cells(row2, 1) = ""
Sheets("Data 14").Select
alarm1 = Cells(row1, 14)
alarm2 = Sheets("Identified Bf 14 alarms").Cells(row2, 1)
If alarm1 < alarm2 Then
row2 = row2 + 1

If Cells(row2, 1) = "" Then
Sheets("Data 14").Select
Cells(row1, 14).Select
Selection.Copy
Sheets("Identified Bf 14 alarms").Select
FindEmptyRow
Cells(row3, 1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Sheets("Data 14").Select
Cells(row1, 4).Select
Selection.Copy
Sheets("Identified Bf 14 alarms").Select
FindEmptyRow
Cells(row3, 2).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Else: row1 = row1 + 1
End If
End If
Loop

Loop



End Sub