adding text to column cell if there's a value present

T

Tim R

I have a column of about 3000 cells...some of them are empty and some have a
number in them from 1 to 4 digits (21 , 454, 1001, 2) etc. These are
address/unit numbers. I'm trying to write a function that will check each
cell and if there's a value in it...write Unit 'value' so I get Unit 454
, etc. If the cell is empty...then there's no "Unit" text added ?

Been trying for awhile but don't seem to be getting close...any ideas on
this type of function ?

Thanks, Tim
 
G

Guest

You can use this IF function to produce the result you need:

=IF(ISNUMBER(A1),"Unit "&A1,"")

Change the Column as needed and copy it down to the last row.

You can also use if the column having unit numbers has something like 12B:

=IF(ISBLANK(A1),"","Unit "&A1)
 
J

Jennifer

I have a column of about 3000 cells...some of them are empty and some have a
number in them from 1 to 4 digits (21 , 454, 1001, 2) etc. These are
address/unit numbers. I'm trying to write a function that will check each
cell and if there's a value in it...write Unit 'value' so I get Unit 454
, etc. If the cell is empty...then there's no "Unit" text added ?

Been trying for awhile but don't seem to be getting close...any ideas on
this type of function ?

Thanks, Tim

The following will work...assuming that your units are in column A and
that the actual unit numbers begin in row 2.

Jennifer

Sub Modify_Text()
Dim X As Integer
Dim sValue As String

For X = 2 To 3000
If Sheet1.Cells(X, 1).Value <> "" Then
sValue = Sheet1.Cells(X, 1).Value
Sheet1.Cells(X, 1).Value = "Unit " & Sheet1.Cells(X,
1).Value
End If
Next X
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top