View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Billy Liddel Billy Liddel is offline
external usenet poster
 
Posts: 527
Default adding text to column cell if there's a value present

Hello Tim

Two ways; 1 add a helper column and assume that the numbers are in column A
type the formula =IF(A2="","","Unit "&A2) and copy down. Select the formulas
and press ctrl & C (copy) then Edit, Paste special and choose values.

The move the new values over the originals.

2nd use a macro. Copy the code into a module in VB Editor, return to Excel,
select the column and choose Tools, Macros and run the macro. - this will
make the changes in situ

Sub WriteUnit()
For Each c In Selection
If c = "" Then
'do nothing
ElseIf IsNumeric(c) Then
c.Value = "Unit " & c
End If
Next
End Sub

Regards
Peter

"Tim R" wrote:

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