I have set it up but when I run it nothing
happens not even an error note etc. I feel the code is right is it
possible that I have formatting or something not set correctly?
I will come back on the time part, yes that will have to be deleted.
Code used:
Option Explicit
Sub Extract_Text_Click()
' Define variables
Dim St1 As Variant
Dim i As Long
Dim Data_rows As Long
Dim Searchstring, Searchchar, MyPos
' Determine number of rows in user selected column to loop through.
' First, select column A
Range("A1").Select
Data_rows = Range(Selection, Selection.End(xlDown)).Rows.Count
' Start looping through column A
For i = 1 To Data_rows
Searchchar = "TOWN STOP---"
Range("A1").Offset(i, 0).Select
Searchstring = ActiveCell.Value
MyPos = InStr(1, Searchstring, Searchchar, 1)
Debug.Print Searchstring, "|||", Searchchar, "|||", MyPos
If MyPos = 1 Then Range("k" & i).Value = Searchstring
Range("k" & i).Replace What:="TOWN STOP---", Replacement:="", _
LookAt:=xlPart _
, SearchOrder:=xlByRows, MatchCase:=False, _
SearchFormat:=False, _
ReplaceFormat:=False
Next i
End Sub
Private Sub ListBox1_Click()
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
End Sub