aryanaveen
Board Regular
- Joined
- Jan 5, 2015
- Messages
- 104
Hi All
I have a problem in bulding my macro, please help
I am using below code to find out the line which contains "USD" and this is working fine. Now is it possible to insert one more condition
All I want is the code should execute the formula only if cell starts with numbers 1 to 9 and ends with USD
ex - 52 6/4/2017 16.00 263.00 4,208.00 0.00 0.00 4,208.00USD
My code -
Range("A1").Select
Dim lrow As Long, rng As Range, cell As Range
lrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set rng = Range("A2:A" & lrow)
For Each cell In rng
If InStr(1, cell.Value, "Service Provider:", vbTextCompare) > 0 Then
cell.Offset(0, 2).FormulaR1C1 = "=RIGHT(RC[-2], LEN(RC[-2])-FIND("":"",RC[-2]))"
cell.Offset(0, 2).Copy
cell.Offset(0, 2).PasteSpecial xlPasteValuesAndNumberFormats
Application.CutCopyMode = False
End If
Next cell
I have a problem in bulding my macro, please help
I am using below code to find out the line which contains "USD" and this is working fine. Now is it possible to insert one more condition
All I want is the code should execute the formula only if cell starts with numbers 1 to 9 and ends with USD
ex - 52 6/4/2017 16.00 263.00 4,208.00 0.00 0.00 4,208.00USD
My code -
Range("A1").Select
Dim lrow As Long, rng As Range, cell As Range
lrow = Cells(Cells.Rows.Count, "A").End(xlUp).Row
Set rng = Range("A2:A" & lrow)
For Each cell In rng
If InStr(1, cell.Value, "Service Provider:", vbTextCompare) > 0 Then
cell.Offset(0, 2).FormulaR1C1 = "=RIGHT(RC[-2], LEN(RC[-2])-FIND("":"",RC[-2]))"
cell.Offset(0, 2).Copy
cell.Offset(0, 2).PasteSpecial xlPasteValuesAndNumberFormats
Application.CutCopyMode = False
End If
Next cell