Sub Here_We_Go()
Dim c As Range
For Each c In Sheets("Sheet1").Range("A2:A" & Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row)
If IsNumeric(c.Value) Then
With Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Offset(1)
.NumberFormat = "@"
.Value = Left(c, 4) & "-" & Mid(c, 5, 3) & "-" & Mid(c, 8)
End With
Else
With Sheets("Sheet3").Cells(Rows.Count, 1).End(xlUp).Offset(1)
.Value = Left(c, 2) & "-" & Mid(c, 3, 2) & "-" & Mid(c, 5)
End With
End If
Next c
End Sub
Hi, How to create fix length and add currency numbers such as 123456789 to 6789.00 or 1234.00Change references where required.
Code:Sub Here_We_Go() Dim c As Range For Each c In Sheets("Sheet1").Range("A2:A" & Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row) If IsNumeric(c.Value) Then With Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Offset(1) .NumberFormat = "@" .Value = Left(c, 4) & "-" & Mid(c, 5, 3) & "-" & Mid(c, 8) End With Else With Sheets("Sheet3").Cells(Rows.Count, 1).End(xlUp).Offset(1) .Value = Left(c, 2) & "-" & Mid(c, 3, 2) & "-" & Mid(c, 5) End With End If Next c End Sub
Member’s nameDo me a favor please. Don't quote unless it is absolutely required, which to my knowledge it very seldom is.
Refer to Post numbers and/or member's name
Sub Here_We_Go()
Dim c As Range
For Each c In Sheets("Sheet1").Range("C2:C" & Sheets("Sheet1").Cells(Rows.Count, 3).End(xlUp).Row)
If IsNumeric(c.Value) Then
With Sheets("Sheet2").Cells(Rows.Count, 1).End(xlUp).Offset(1)
.NumberFormat = "@"
.Value = Left(c, 4) & ".00" & "-" & Mid(c, 5, 3) & ".00" & "-" & Mid(c, 8) & ".00"
End With
Else
With Sheets("Sheet3").Cells(Rows.Count, 1).End(xlUp).Offset(1)
.Value = Left(c, 2) & "-" & Mid(c, 3, 2) & "-" & Mid(c, 5)
End With
End If
Next c
End Sub