View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Joe Mac Joe Mac is offline
external usenet poster
 
Posts: 40
Default Retrieving Excel data to post to a form

All...

I'm running into a couple of issues when attempting to run the code below
and would appreciate any assistance in what I'm doing incorrectly... First
is an Overflow issue when attempting to set a LookupID variable, secondly,
I'm not sure whether the RowIndex variable is structured properly...

Here is what I'm attempting to do:
I have a 10 digit numeric value that is stored in Excel using a form; I now
want to use the same 10 digit numeric field to allow the User to find the
specific Row of data and display the corresponding fields to a new form...

Here is the code that I'm attempting to run:
Private Sub ReferenceID_Exit(ByVal Cancel As MSForms.ReturnBoolean)
Dim LastRow As Long
Dim LookupID As Long
Dim RowIndex As Long

LastRow = (Selection.CurrentRegion.Rows.Count)

If IsNumeric(Me.ReferenceID.Text) Then
LookupID = (CLng(Me.ReferenceID.Text))
Else
Me.ReferenceID.Text = ""
MsgBox "Reference ID number must be numeric."
Cancel = True
End If

With Worksheets("Raw Data").Range("C1:C" & LastRow)
Set RowIndex = (Selection.Find(What:=LookupID, After:=ActiveCell,
LookIn:=xlValues, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Row)
End With

Department.Text = Cells(RowIndex, 1)
Department.Text = Cells(RowIndex, 2)
Department.Text = Cells(RowIndex, 3)
Department.Text = Cells(RowIndex, 4)
Department.Text = Cells(RowIndex, 5)
Department.Text = Cells(RowIndex, 6)
Department.Text = Cells(RowIndex, 7)
Department.Text = Cells(RowIndex, 8)
End Sub


--

Joe Mac