Probably a noob question, i am struggling with getting a piece of code to run.
I have a textbox in which in which the user enters a number, and if it is in between a certain range which is defined in a table, it responds and displays data in 2 different textboxes.
However see code below, I am getting a compile error on "for each i"
I can solve this by putting "Dim i As Range"
But then i get the same error on "Receiver Data" which is my worksheet name.
I have a textbox in which in which the user enters a number, and if it is in between a certain range which is defined in a table, it responds and displays data in 2 different textboxes.
However see code below, I am getting a compile error on "for each i"
I can solve this by putting "Dim i As Range"
But then i get the same error on "Receiver Data" which is my worksheet name.
VBA Code:
Private Sub TextBox4_AfterUpdate()
Dim ID As Long
Dim StartID As Long
Dim EndID As Long
If TextBox4.Value = "" Then
Else
ID = TextBox4.Value
For Each i In ReceiverData.Range("Table2[From]")
StartID = i.Value
EndID = i.Offset(0, 1).Value
If ID >= StartID And ID < EndID Then
TextBox5.Value = i.Offset(0, 3).Value
TextBox6.Value = i.Offset(0, 4).Value
TextBox7.Value = i.Offset(0, 5).Value
End If
Next i
End If
End Sub