Run-Time Error 438 Object Doesn't Support this property

FuNeS13

Board Regular
Joined
Oct 25, 2016
Messages
161
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
  2. Mobile
  3. Web
I'm bumping to this error with this code... Anyone know how can it be fixed? I tried several different options but none seem to work...


Code:
Private Sub TextBox1_AfterUpdate()



With Me


Dim sht1 As Worksheet, sht2 As Worksheet, wb As Workbook


Set wb = ActiveWorkbook
Set sht1 = wb.Worksheets("Data")
Set sht2 = wb.Worksheets("Entries")


Dim I As Long
I = Worksheets(2).Range("A1048576").End(xlUp).Offset(1, 0).Row




    
    .TextBox2 = Application.WorksheetFunction.VLookup(CLng(Me.TextBox1), wb.sht1.Range("A2:G835"), 2, 0)  '<<-- Error appears here... 
    .TextBox3 = Application.WorksheetFunction.VLookup(CLng(Me.TextBox1), wb.sht1.Range("A2:G835"), 3, 0)
    .TextBox4 = Application.WorksheetFunction.VLookup(CLng(Me.TextBox1), wb.sht1.Range("A2:G835"), 4, 0)
    .TextBox5 = Application.WorksheetFunction.VLookup(CLng(Me.TextBox1), wb.sht1.Range("A2:G835"), 5, 0)
    
        
    .TextBox8 = Time()


End With

End Sub
 
Last edited:

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Remove the wb. from the vlookup so it's just sht1.Range...
 
Upvote 0
Remove the wb object:

Code:
Private Sub TextBox1_AfterUpdate()
  With Me
    Dim sht1 As Worksheet, sht2 As Worksheet, wb As Workbook
    Set wb = ActiveWorkbook
    Set sht1 = wb.Worksheets("Data")
    Set sht2 = wb.Worksheets("Entries")
    Dim I As Long
    I = Worksheets(2).Range("A1048576").End(xlUp).Offset(1, 0).Row
    .TextBox2 = Application.WorksheetFunction.VLookup(CLng(Me.TextBox1), [COLOR=#0000ff]sht1[/COLOR].Range("A2:G835"), 2, 0)
    .TextBox3 = Application.WorksheetFunction.VLookup(CLng(Me.TextBox1), sht1.Range("A2:G835"), 3, 0)
    .TextBox4 = Application.WorksheetFunction.VLookup(CLng(Me.TextBox1), sht1.Range("A2:G835"), 4, 0)
    .TextBox5 = Application.WorksheetFunction.VLookup(CLng(Me.TextBox1), sht1.Range("A2:G835"), 5, 0)
    .TextBox8 = Time()
  End With
End Sub
 
Upvote 0
After I do that I now get Run-Time Error 1004 - Unable to get the Vlookup property of the worksheetfunction class...
 
Upvote 0
Some recommendations.
- If you use a single userform it is not necessary Me.
- Use the Find method, that way only perform a single search.
Try this:

Code:
Private Sub TextBox1_AfterUpdate()
  Dim sht1 As Worksheet, sht2 As Worksheet, wb As Workbook
  Dim I As Long, f As Range
  Set wb = ActiveWorkbook
  Set sht1 = wb.Worksheets("Data")
  Set sht2 = wb.Worksheets("Entries")
  I = sht2.Range("A1048576").End(xlUp).Offset(1, 0).Row
  Set f = sht1.Range("A2:A835").Find(CLng(TextBox1), , xlValues, xlWhole)
  If Not f Is Nothing Then
    TextBox2 = f.Offset(, 1)
    TextBox3 = f.Offset(, 2)
    TextBox4 = f.Offset(, 3)
    TextBox5 = f.Offset(, 4)
    TextBox8 = Time()
  End If
End Sub
 
Upvote 0
That means it can't find the textbox value, try it like
Code:
Private Sub TextBox1_AfterUpdate()
   Dim sht1 As Worksheet, sht2 As Worksheet, wb As Workbook
   Dim Res As Variant
   
   Set wb = ActiveWorkbook
   Set sht1 = wb.Worksheets("Data")
   Set sht2 = wb.Worksheets("Entries")
   
   With Me
      Res = Application.VLookup(CLng(Me.TextBox1), wb.sht1.Range("A2:G835"), 2, 0)
      If Not IsError(Res) Then .TextBox2 = Res
      Res = Application.VLookup(CLng(Me.TextBox1), wb.sht1.Range("A2:G835"), 3, 0)
      If Not IsError(Res) Then .TextBox3 = Res
           
       .TextBox8 = Time()
   End With

End Sub

My turn to be too slow :)
 
Last edited:
Upvote 0
Thank you both, Fluff options gives the 438 error, and Dante's IF statement just goes to the END IF part... It was working before... not sure where in the process this stop working...
 
Upvote 0
I forgot to remove the wb. part, but it doesn't change the fact that your textbox value is not being found in A2:A835 on the data sheet.
 
Upvote 0
Change the wb.sht1 in Fluff's code to just sht1
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,334
Members
452,636
Latest member
laura12345

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