ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,227
- Office Version
- 2007
- Platform
- Windows
Morning,
I have the code shown below.
I see messages like expected end of statement.
This is because the worksheet is called MC LIST
As a test i changed the name to LIST & its fine but why am i unable to have MC LIST
Does the space have any issues between the two words ?
I have the code shown below.
I see messages like expected end of statement.
This is because the worksheet is called MC LIST
As a test i changed the name to LIST & its fine but why am i unable to have MC LIST
Does the space have any issues between the two words ?
Rich (BB code):
Private Sub TextBox1_BeforeUpdate(ByVal Cancel As MSForms.ReturnBoolean)
Dim fndRng As Range
Dim FindString As String
Dim i As Integer
Dim wsMC LIST As Worksheet
FindString = Me.TextBox1.Value
If Len(FindString) = 0 Then Exit Sub
Set wsMC LIST = ThisWorkbook.Worksheets("LIST")
i = 1
Do
Set fndRng = Nothing
Set fndRng = wsMC LIST.Range("A:A").Find(What:=FindString & Format(i, " 000"), _
LookIn:=xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, _
SearchDirection:=xlNext, MatchCase:=False)
If Not fndRng Is Nothing Then
i = i + 1
Cancel = True
End If
Loop Until fndRng Is Nothing
Me.TextBox1.Value = FindString & Format(i, " 000")
Cancel = False
End Sub