PDA

View Full Version : basic syntax query



JZB
04-30-2009, 01:49 AM
Hi guys

I have a list of data, some codes with numbers and letters e.g 25H and other just numbers e.g 25

I want to add a 0 at the front of the numbers only.

so real basic loop but how do i word the condition? i basically want to say

If activecell = number then

Activecell = "0"& activecell

End if

sorry, pretty basic stuff i know :dunno

Bob Phillips
04-30-2009, 02:35 AM
Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim LastRow As Long

With ActiveSheet

LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To LastRow

If IsNumeric(.Cells(i, TEST_COLUMN).Value) Then

.Cells(i, TEST_COLUMN).Value = "'0" & .Cells(i, TEST_COLUMN).Value
End If
Next i
End With

End Sub

JZB
04-30-2009, 06:37 AM
really good method. thanks :bow: