Sub Test()
With Range("A2:E" & Cells(Rows.Count, 1).End(xlUp).Row)
.NumberFormat = "£0.00"
End With
End Sub
Can you illustrate with an example ?The number of cells changes so it needs to look at the whole rows
Sub Test()
Dim rCell As Range
For Each rCell In Range("A2:E" & Cells(Rows.Count, 1).End(xlUp).Row)
With rCell
.Formula = "=TEXT(" & rCell.Value & ",""£0.00"")"
.Value = .Text
End With
Next rCell
End Sub
Try this code as I didn't notice you need to format as text
Code:Sub Test() Dim rCell As Range For Each rCell In Range("A2:E" & Cells(Rows.Count, 1).End(xlUp).Row) With rCell .Formula = "=TEXT(" & rCell.Value & ",""£0.00"")" .Value = .Text End With Next rCell End Sub
Sub Test1()
Dim rCell As Range
For Each rCell In Selection ' Range("A2:E" & Cells(Rows.Count, 1).End(xlUp).Row)
rCell.Value = CStr(Format(rCell, "£0.00"))
Next
End Sub
could you alter this so that rows e,f j and i are changed? Apologies but I am a beginnerIn this case this would be simple.
Code:Sub Test1() Dim rCell As Range For Each rCell In Selection ' Range("A2:E" & Cells(Rows.Count, 1).End(xlUp).Row) rCell.Value = CStr(Format(rCell, "£0.00")) Next End Sub