PC Review


Reply
Thread Tools Rate Thread

Auto Insert Parenthesis

 
 
Deb
Guest
Posts: n/a
 
      11th Jan 2010
How do I auto-insert parethesis around prepopulated data in a worksheet? I
have a column of information that only if there is information, then I would
like it to be in parenthesis. For example,

A1: data
B1: data
C1: no data
D1: no data
E1: data

I would like to auto-insert parenthesis around the cells that show "data"
but to ignore cells that have "no data". This would involve only 1 column in
the excel file. The cells that contain data would look like this, example:
(Smith) or (Jones) rather than Smith or Jones.
 
Reply With Quote
 
 
 
 
Gord Dibben
Guest
Posts: n/a
 
      11th Jan 2010
Sub parens()
Dim rng1 As Range
Set rng1 = ActiveSheet.Range(Cells(1, 1), _
Cells(Rows.Count, 1).End(xlUp))
For Each cell In rng1
If cell.Value <> "" Then
cell.Value = "(" & cell.Value & ")"
End If
Next
End Sub



Gord Dibben MS Excel MVP

On Mon, 11 Jan 2010 07:10:01 -0800, Deb <(E-Mail Removed)>
wrote:

>How do I auto-insert parethesis around prepopulated data in a worksheet? I
>have a column of information that only if there is information, then I would
>like it to be in parenthesis. For example,
>
>A1: data
>B1: data
>C1: no data
>D1: no data
>E1: data
>
>I would like to auto-insert parenthesis around the cells that show "data"
>but to ignore cells that have "no data". This would involve only 1 column in
>the excel file. The cells that contain data would look like this, example:
>(Smith) or (Jones) rather than Smith or Jones.


 
Reply With Quote
 
Deb
Guest
Posts: n/a
 
      12th Jan 2010
Thanks, Gord. This works excellent. Now if I could ask one more favor? How
can I get this to work in a specific column? The data I am trying to
manipulate is in column E. The current module wants to apply the info to
column A. If this is an impossible request, I think I know a way to move the
columns around so that the present module will work. Thank you so much.

"Gord Dibben" wrote:

> Sub parens()
> Dim rng1 As Range
> Set rng1 = ActiveSheet.Range(Cells(1, 1), _
> Cells(Rows.Count, 1).End(xlUp))
> For Each cell In rng1
> If cell.Value <> "" Then
> cell.Value = "(" & cell.Value & ")"
> End If
> Next
> End Sub
>
>
>
> Gord Dibben MS Excel MVP
>
> On Mon, 11 Jan 2010 07:10:01 -0800, Deb <(E-Mail Removed)>
> wrote:
>
> >How do I auto-insert parethesis around prepopulated data in a worksheet? I
> >have a column of information that only if there is information, then I would
> >like it to be in parenthesis. For example,
> >
> >A1: data
> >B1: data
> >C1: no data
> >D1: no data
> >E1: data
> >
> >I would like to auto-insert parenthesis around the cells that show "data"
> >but to ignore cells that have "no data". This would involve only 1 column in
> >the excel file. The cells that contain data would look like this, example:
> >(Smith) or (Jones) rather than Smith or Jones.

>
> .
>

 
Reply With Quote
 
Gord Dibben
Guest
Posts: n/a
 
      12th Jan 2010
You must change the column reference

See the pattern for (row, column)

Sub parens()
Dim rng1 As Range
Set rng1 = ActiveSheet.Range(Cells(1, 5), _ ' row1, column5
Cells(Rows.Count, 5).End(xlUp)) 'column5
For Each cell In rng1
If cell.Value <> "" Then
cell.Value = "(" & cell.Value & ")"
End If
Next
End Sub

This would also work.

Sub parens()
Dim rng1 As Range
Set rng1 = ActiveSheet.Range(Cells(1, "E"), _
Cells(Rows.Count, "E").End(xlUp))
For Each cell In rng1
If cell.Value <> "" Then
cell.Value = "(" & cell.Value & ")"
End If
Next
End Sub


Gord

On Tue, 12 Jan 2010 06:22:01 -0800, Deb <(E-Mail Removed)>
wrote:

>Thanks, Gord. This works excellent. Now if I could ask one more favor? How
>can I get this to work in a specific column? The data I am trying to
>manipulate is in column E. The current module wants to apply the info to
>column A. If this is an impossible request, I think I know a way to move the
>columns around so that the present module will work. Thank you so much.
>
>"Gord Dibben" wrote:
>
>> Sub parens()
>> Dim rng1 As Range
>> Set rng1 = ActiveSheet.Range(Cells(1, 1), _
>> Cells(Rows.Count, 1).End(xlUp))
>> For Each cell In rng1
>> If cell.Value <> "" Then
>> cell.Value = "(" & cell.Value & ")"
>> End If
>> Next
>> End Sub
>>
>>
>>
>> Gord Dibben MS Excel MVP
>>
>> On Mon, 11 Jan 2010 07:10:01 -0800, Deb <(E-Mail Removed)>
>> wrote:
>>
>> >How do I auto-insert parethesis around prepopulated data in a worksheet? I
>> >have a column of information that only if there is information, then I would
>> >like it to be in parenthesis. For example,
>> >
>> >A1: data
>> >B1: data
>> >C1: no data
>> >D1: no data
>> >E1: data
>> >
>> >I would like to auto-insert parenthesis around the cells that show "data"
>> >but to ignore cells that have "no data". This would involve only 1 column in
>> >the excel file. The cells that contain data would look like this, example:
>> >(Smith) or (Jones) rather than Smith or Jones.

>>
>> .
>>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
is there an auto punctuation insert like the auto spell determined09 Microsoft Word Document Management 1 21st Sep 2009 08:17 PM
Need VBA script to auto-insert value upon row insert Phil Microsoft Excel Worksheet Functions 4 6th May 2008 02:41 PM
Can I auto insert a worksheet when I insert a value in a cell. =?Utf-8?B?aWFpbmM=?= Microsoft Excel Worksheet Functions 0 27th Apr 2006 08:37 AM
When I try to insert a header I can't click on 'insert auto text' =?Utf-8?B?TWVs?= Microsoft Access 1 6th May 2005 08:56 AM
Insert cell/format/text/fontsize and auto insert into header? =?Utf-8?B?VW5mdXJsdGhlZmxhZw==?= Microsoft Excel Programming 2 3rd Nov 2004 05:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:39 PM.