Hi there,
Many thanks for anyone's response which will help be quickly clear up my situation. I have a Userform on an Excel spreadsheet which consists of two Multipages (the main one and a sub one which isn't related to this query).
I have one of the multipages currently being used as a Lookup function. When you type the lookup value (as you would with standard VLOOKUP) it returns the 7 values I require into another 7 textboxes. The code I had worked perfectly until I added code to enable a minimize/maximize button on the Userform and added a function to inform the user of an un-returned value because it is not stored in the database.
The code I current have is the following:
Private Sub TextBox13_AfterUpdate()
Dim FindR As Variant
Application.Visible = True
Worksheets("Sheet5").Visible = True
'Start searching from top of column and activate the cell containing lookup value entered into TextBox13
Worksheets("Sheet5").Select
Range("A1").Select
Cells.FindNext(After:=ActiveCell).Activate
FindR = Cells.Find(What:=UserForm1.TextBox13.Text, After:=ActiveCell, LookIn:=xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=True).Activate
'If TextBox13 value isn't found, advise user and fill textboxes with dashes
If FindR Is Nothing Then
MsgBox ("Not currently stored in database.")
TextBox12.Value = "-"
TextBox14.Value = "-"
TextBox15.Value = "-"
TextBox16.Value = "-"
TextBox19.Value = "-"
TextBox17.Value = "-"
TextBox18.Value = "-"
'If TextBox13 text is found, put details into textboxes on UserForm.
Else
'set the contents of text1 to the contents of the cell 1 to the left etc
TextBox12.Value = ActiveCell.Offset(0, 1).Value
TextBox14.Value = ActiveCell.Offset(0, 2).Value
TextBox15.Value = ActiveCell.Offset(0, 3).Value
TextBox16.Value = ActiveCell.Offset(0, 4).Value
TextBox19.Value = ActiveCell.Offset(0, 5).Value
TextBox17.Value = ActiveCell.Offset(0, 7).Value
TextBox18.Value = ActiveCell.Offset(0, 8).Value
The TextBox and ActiveCell.Offset's are definitely correct so they do not need changed however I am still dumbfounded as to why I am receiving a Run Time Error 91 (Object Variable or With block variable not set) error where it then higlights 'Cells.FindNext(After:=ActiveCell).Activate'
The lookup works fine if I take out IF function part for informing the user the value was not returned but this is an option I HAVE to have built in.
Does anyone know where I am going wrong?
~Liam
Bookmarks