i want to extract text from Cells in Column A and put it in Column C
Excel: C2= Right (A2;2)
VBA code i used:
Private Sub CommandButton1_Click()
Dim sh1 As Worksheet
Set sh1 = Sheets("Sheet1")
a = sh1.Range("A2:D" & sh1.Range("A" & Rows.Count).End(3).Row).Value2
For i = 1 To UBound(a, 1)
If Right(a(i, 1), 2) = "CP" Then
a(i, 3) = "CP"
End If
Next
End Sub
When I press the button, nothing happpened.
Excel: C2= Right (A2;2)
VBA code i used:
Private Sub CommandButton1_Click()
Dim sh1 As Worksheet
Set sh1 = Sheets("Sheet1")
a = sh1.Range("A2:D" & sh1.Range("A" & Rows.Count).End(3).Row).Value2
For i = 1 To UBound(a, 1)
If Right(a(i, 1), 2) = "CP" Then
a(i, 3) = "CP"
End If
Next
End Sub
When I press the button, nothing happpened.
name | number | extracted text |
text1cp | 400 | |
bcncp | 401 | |
34454cp | 402 | |
cdffcp | 403 | |
…. | …. | …. |