NessPJ
Active Member
- Joined
- May 10, 2011
- Messages
- 416
- Office Version
- 365
Hi all,
I have a value in Cell A1 of:
HBST-MC022 1551401715514017AAA202007171210167738324000000L0511011111111
I am using the following code to try and determine if the string contains "HBST-MC022".
Yet my code keeps returning 0. When the first Cell actually contains the value. Am i doing something wrong?
I have a value in Cell A1 of:
HBST-MC022 1551401715514017AAA202007171210167738324000000L0511011111111
I am using the following code to try and determine if the string contains "HBST-MC022".
Yet my code keeps returning 0. When the first Cell actually contains the value. Am i doing something wrong?
VBA Code:
Private Sub MC022Test()
Dim CheckMC022 As Long
'Set variables used for all interfaces to process
Set Rng = Sheets("i21").Range("A1:A1000")
'Loop each cell in range
For Each Cell In Rng.Cells
WriteCell = Cell.Offset(0, 12).Address
CheckMC022 = InStr(0, Cell.text, "HBST-MC022", vbTextCompare)
Debug.Print CheckMC022
End Sub