ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,226
- Office Version
- 2007
- Platform
- Windows
I have a worksheet called SKP IMMO LIST
I am using the code below.
My problem is that after making my selections on the user form i then press the CommandButton1 but a see a run time error9,subscript out of range.
This code is then shown in yellow,
Set wsSKPIMMOLIST = ThisWorkbook.Worksheets("SKPIMMOLIST")
But i dont see why ?
The sheet has a space between each word so its like this SKP IMMO LIST
If i put that where its shown in yellow then it makes things even worse etc
So i closed it up thinking the space was the issue but no ??
I am using the code below.
My problem is that after making my selections on the user form i then press the CommandButton1 but a see a run time error9,subscript out of range.
This code is then shown in yellow,
Set wsSKPIMMOLIST = ThisWorkbook.Worksheets("SKPIMMOLIST")
But i dont see why ?
Code:
Private Sub CommandButton1_Click()
Dim i As Integer
Dim LastRow As Long
Dim wsSKPIMMOLIST As Worksheet
Set wsSKPIMMOLIST = ThisWorkbook.Worksheets("SKPIMMOLIST")
For i = 1 To 6
With Me.Controls("TextBox" & i)
If .Text = "" Then
MsgBox Choose(i, "Vehicle", "Year", "Button", _
"Chip", "Immo", "Notes") & _
" Not Entered", vbCritical, "SKP IMMO LIST"
.SetFocus
Exit Sub
End If
End With
Next i
With wsSKPIMMOLIST
LastRow = .Cells(.Rows.Count, 2).End(xlUp).Row + 1
End With
For i = 1 To 6
With Me.Controls("TextBox" & i)
wsSKPIMMOLIST.Cells(LastRow, i * 2).Value = .Text
.Text = ""
End With
Next i
MsgBox "SKP IMMO LIST UPDATED", vbInformation, "SKP IMMO LIST"
TextBox1.SetFocus
End Sub
The sheet has a space between each word so its like this SKP IMMO LIST
If i put that where its shown in yellow then it makes things even worse etc
So i closed it up thinking the space was the issue but no ??
Last edited: