So, I have what I hope is a simple issue to resolve. I'm working within IE and through various event handlers and such I have my code set up to automatically perform a task in IE when ever a cell in column "A" is selected. At the end of the code (which you can see below) it advances the selection down one cell which triggers the code to run again. This almost works perfectly. The problem I have is when I filter my list. For instance if I'm only viewing rows 1-5 and 20-30 due to my filters, when the code completes on row 5 it advances down and selects row 6 when I really need it to select row 20. This unfortunately breaks my code because I only want it to run on the rows that I've filtered for viewing. Does anybody know a way of selecting the next filtered cell?
VBA Code:
Sub Cycle_Assignment()
Dim ie As Object
Set ie = GetIE
Dim Enumber As String
Set Enumber = ActiveCell.Offset(0, 3).Value
On Error Resume Next
ie.Visible = True
Dim rCell As Range
Dim sMyString As String
Set rCell = ActiveCell
For Each Cell In rCell
If Len(rCell.Formula) = 0 Then
Application.EnableEvents = False
MsgBox "List Complete"
ie.Quit
'Exit Sub
Else
Application.Wait (Now + TimeValue("0:00:01"))
ie.Document.all("ddlFacility").Value = "TH"
ie.Document.all("TextBox_TagNum").Value = ActiveCell.Value
Set objButton = ie.Document.all("TextBox_TagNum")
objButton.Focus
objButton.Click
Application.Wait (Now + TimeValue("0:00:01"))
Application.SendKeys "~"
Application.Wait (Now + TimeValue("0:00:01"))
ie.Document.all("GridView_CyclesFound_DropDownList_NewTech_0").Value = Enumber
ie.Document.all("GridView_CyclesFound_DropDownList_NewTech_1").Value = Enumber
ie.Document.all("GridView_CyclesFound_DropDownList_NewTech_2").Value = Enumber
ie.Document.all("GridView_CyclesFound_DropDownList_NewTech_3").Value = Enumber
Application.Wait (Now + TimeValue("0:00:01"))
ie.Document.all("Button_UpdateAll").Click
Application.Wait (Now + TimeValue("0:00:01"))
ie.Document.all("Button_Clear").Click
'ie.Quit
Application.Wait (Now + TimeValue("0:00:01"))
ActiveCell.Offset(0, 8).Value = "P"
'Application.SendKeys "{DOWN}" 'This doesnt work at all
ActiveCell.Offset(1, 0).Select
End If
Next
End Sub