Pookiemeister
Well-known Member
- Joined
- Jan 6, 2012
- Messages
- 626
- Office Version
- 365
- 2010
- Platform
- Windows
On my userform, I have six option buttons and three textboxes. When I run this code I get the following runtime error '91.
The following line of code is highlighted in yellow:
The error states that the object variable is not set, but it is. Why am I getting this error?
Thank You
Code:
Option Explicit
Dim sPath As String, sFile As String
Dim wb As Workbook
Dim ws As Worksheet
Dim rng As Range
Private Sub cmdbtnOpen_Click()
sPath = "C:\Production_Line\"
Select Case True
Case Is = optSlits
sFile = sPath & "SDPF - LINE 1 .xlsx"
Case Is = optMann
sFile = sPath & "SDPF - LINE 2A.xlsx"
Case Is = optCorb
sFile = sPath & "SDPF - LINE 3.xlsx"
Case Is = optIA
sFile = sPath & "SDPF - LINE 4.xlsx"
Case Is = optMann5
sFile = sPath & "SDPF - LINE 5A.xlsx"
Case Is = optPouch
sFile = sPath & "SDPF - LINE 6.xlsx"
End Select
Select Case True
Case Is = optSlits
Worksheets("SDPF - LINE 1").Activate
Case Is = optMann
Worksheets("SDPF - LINE 2A").Activate
Case Is = optCorb
Worksheets("SDPF - LINE 3").Activate
Case Is = optIA
Worksheets("SDPF - LINE 4").Activate
Case Is = optMann5
Worksheets("SDPF - LINE 5A").Activate
Case Is = optPouch
Worksheets("SDPF - LINE 6").Activate
End Select
Set wb = Workbooks.Open(sFile)
Unload Me
Set rng = ws.Range("G:G").Find(Me.TextBox3.Value)
End Sub
Code:
Set rng = ws.Range("G:G").Find(Me.TextBox3.Value)
Thank You
Last edited: