VBA Code - Run-time error '438'

glerwell

Well-known Member
Joined
Jun 25, 2006
Messages
1,082
Hi

Can somebody please tell me why I seem to be having a runtime error '438' error with the following code.

I have modified it from my original code but now I seem to be getting this error :confused:

Code:
Code:
Option Explicit
Private Sub CommandButton1_Click()
Dim iRow As Long
Dim ws As Worksheet
Dim Rng As Range
With Worksheets("BETS")
If .Range("B16").Value = "" Then
Set Rng = .Range("B16")
ElseIf .Range("B17") = "" Then
Set Rng = .Range("B17")
Else
Set Rng = .Range("B16").End(xlDown).Offset(1, 0)
End If

With Rng
.Offset(0, 0).Value = Me.ComboBox1.Value
.Offset(0, 1).Value = Me.ComboBox2.Value
.Offset(0, 2).Value = Me.ComboBox3.Value
End With
        
With .Offset(0, 4)
.Formula = "=VLOOKUP(B" & Rng.Row & ",'BETTING BANKS'!$B$16:$O$60,14,FALSE)"
.Value = .Value
End With
        
With .Offset(0, 6)
.Formula = "=VLOOKUP(B" & Rng.Row & ",'SYSTEMS'!$B$16:$D$76,3,FALSE)"
.Value = .Value
End With
        
With .Offset(0, 8)
.Formula = "=VLOOKUP(B" & Rng.Row & ",'BETTING BANKS'!$B$16:$O$60,12,FALSE)"
.Value = .Value

With .Offset(0, 5)
.Formula = "=IF(H" & Rng.Row & "=2,""EXCHANGE"",""BOOKMAKER"")"
.Value = .Value
End With
End With
End With
Call copy_selections
Call sortselections
Unload Me
add_selection.Show
End Sub
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Hi,

I can't tell from your post whether you have your code indented or not, but if you don't then it would help you to see the problem if you did. Cutting out the "noise", the first problem is essentially this:

Code:
    With Worksheets("BETS")
       '..... code in here
 
        With .Offset(0, 4)
The worksheet class doesn't have an Offset property, so you get a RTE 438 error. Presumably this should be an offset from a range?

Hope that helps...
 
Upvote 0
thanks guys I got it working now, I added "With RNG" to the code before "With .Offset(0, 4)"
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,603
Members
449,038
Latest member
Arbind kumar

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