we need modify the program to copy values at the end of string after sing “/” or between two signs “/” from column C to new column H. Our program does not work right, it only copy the first occurence and must the last occurence between two sing / /.
enter image description here
Sub Copyvalue()
Dim lookfor As String
Dim i As Integer
Dim j As Integer
Dim cellval As Variant
Dim lastrow As Integer
lookfor = "/"
' Column C
Const colNo = 3
' this for loop is not neccessary as you would loop
' over all columns from 1 to 20
' For j = 1 To 20
lastrow = ActiveSheet.UsedRange.Rows.Count
For i = 1 To lastrow
' Split the string into an array
cellval = Split(Cells(i, colNo).Value, lookfor)
' In case there is no lookfor in the cell
' the next line would error out
On Error Resume Next
' in case there is a lookfor in the string
' the second item of the array will contain
' what you are after and will write it to column G
Cells(i, colNo + 5) = cellval(1)
' reset error handling
On Error GoTo 0
Next i
' Next j
End Sub