Query loop not working properly

VladM

New Member
Joined
Jul 16, 2015
Messages
1
This is essentially what I need to code to do:


  1. Clear Sheet X
  2. Find the first / next “Waiting” text in column 3 of the “Tracker” sheet
  3. Create a Query on Sheet X (in cell A1) with the address “http://efm/telecom/engineeringWorkOrders/viewEWOStatusLog.aspx?ewonumber=” + the corresponding # in column 1 of the same row (as the matching “waiting” text in step 2)
  4. Check if the date in cell B1 of Sheet X is >= date in column 49 (of the corresponding row) on “Tracker” Sheet.
    1. If the date is >= then write “Check!” in column 48 of the “Tracker” sheet of the corresponding row
  5. Repeat the loop until the last “Waiting” has been found in column 3 of the “Tracker” sheet (Step 2)


Here’s what I got so far:


Dim CurRow As Long, LastRow As Long, DestRow As Long
LastRow = Sheets("Tracker").Range("C" & Rows.Count).End(xlUp).Row
For CurRow = 1 To LastRow
If Sheets("Tracker").Range("C" & CurRow).Value = "Waiting" Then
DestRow = Sheets("X").Range("A" & Rows.Count).End(xlUp).Row + 1
With Worksheets("X").QueryTables.Add(Connection:= _
"URL;http://efm/telecom/engineeringWorkOrders/viewEWOStatusLog.aspx?ewonumber=" & Sheets("Tracker").Range("A" & CurRow).Value _
, Destination:=Worksheets("X").Range("A1"))
' Details of Query have been omitted for simplicy sake
End With
End If
If Sheets("Tracker").Range("AW" & CurRow).Value > Sheets("X").Range("B1").Value Then
Sheets("Tracker").Range("AV" & CurRow).Value = "Check!"
End If
With Sheets("X")
.Rows(1 & ":" & .Rows.Count).DELETE
End With
Next CurRow
End Sub

The problem I’m having is that step 4 and 5 is not working!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,223,939
Messages
6,175,530
Members
452,651
Latest member
wordsearch

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top