Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default adding text to column cell if there's a value present

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





  #2   Report Post  
Posted to microsoft.public.excel.misc
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






  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default adding text to column cell if there's a value present

In addition to Billy's excellent suggestions, you can select the cells and:

Format Cells... Number Custom General" Unit"

This adds the text only if the cell is not empty. The cells can also be
added, etc. just like other numbers.
--
Gary''s Student - gsnu2007


"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






  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 527
Default adding text to column cell if there's a value present

Neat one Gary!

I would never have thought of that, and Format Cells... Number Custom
"Unit "General will place Unit before the number, Who would have...


Peter

"Gary''s Student" wrote:

In addition to Billy's excellent suggestions, you can select the cells and:

Format Cells... Number Custom General"Unit "

This adds the text only if the cell is not empty. The cells can also be
added, etc. just like other numbers.
--
Gary''s Student - gsnu2007


"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






  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default adding text to column cell if there's a value present

I like it too. We get to combine numbers with text and still use them as
numbers!
--
Gary''s Student - gsnu2007


"Billy Liddel" wrote:

Neat one Gary!

I would never have thought of that, and Format Cells... Number Custom
"Unit "General will place Unit before the number, Who would have...


Peter

"Gary''s Student" wrote:

In addition to Billy's excellent suggestions, you can select the cells and:

Format Cells... Number Custom General"Unit "

This adds the text only if the cell is not empty. The cells can also be
added, etc. just like other numbers.
--
Gary''s Student - gsnu2007


"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








  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,651
Default adding text to column cell if there's a value present

See the replies to your post of a couple of hours earlier than this one.
--
David Biddulph

"Tim R" wrote in message
...
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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding text to column cell if there's a value present Tim R Excel Discussion (Misc queries) 3 October 23rd 07 10:30 PM
adding up number of people present at certain times bamboozled Excel Worksheet Functions 4 September 18th 07 09:02 AM
Need to parse column data only when text is present Phil Excel Worksheet Functions 0 July 10th 07 08:22 PM
Forgotten a Simple Forumla - Is Text present in another column samprince Excel Discussion (Misc queries) 3 August 4th 06 04:22 PM
SUM/COUNT column(s) based on specific value present within the column markx Excel Worksheet Functions 6 March 22nd 05 10:23 AM


All times are GMT +1. The time now is 05:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"