Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 504
Default How do I automate bracketing of text in an Excel cell?

I have a column of text that all begin and end with a bracket ([]). The text
varies, but the start and finish should all show brackets. How do I automate
the entry of this after all the text is entered. I tried to create a macro by
typing the first bracket, then entering the "end" key and typing the end
bracket. That routine copied all the text between the brackets, as well as
the brackets. Any ideas?
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,520
Default How do I automate bracketing of text in an Excel cell?

If you are looking for a macro to convert the entries to this format then try
the below macro.

Sub Macro1()
Dim lngRow As Long
For lngRow = 1 To Cells(Rows.Count, "A").End(xlUp).Row
If Range("A" & lngRow) < "" And Left(Range("A" & lngRow), 1) < "[" Then
Range("A" & lngRow) = "[" & Range("a" & lngRow).Text & "]"
End If
Next
End Sub

'If you are looking to automate this as soon as you type try the below
worksheet event. Select the sheet tab which you want to work with. Right
click the sheet tab and click on 'View Code'. This will launch VBE. Paste the
below code to the right blank portion. Get back to to workbook and try out.


Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 And Target.Count = 1 Then
If Target.Text < "" And Left(Target.Text, 1) < "[" Then
Application.EnableEvents = False
Target = "[" & Target.Text & "]"
Application.EnableEvents = True
End If
End If
End Sub



--
Jacob


"Kevin" wrote:

I have a column of text that all begin and end with a bracket ([]). The text
varies, but the start and finish should all show brackets. How do I automate
the entry of this after all the text is entered. I tried to create a macro by
typing the first bracket, then entering the "end" key and typing the end
bracket. That routine copied all the text between the brackets, as well as
the brackets. Any ideas?

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 535
Default How do I automate bracketing of text in an Excel cell?

Hi Kevin,

I have a column of text that all begin and end with a bracket ([]). The text
varies, but the start and finish should all show brackets. How do I automate
the entry of this after all the text is entered. I tried to create a macro by
typing the first bracket, then entering the "end" key and typing the end
bracket.


A formula will do:

="[" & A2 & "]"

Copy down to match your # of rows.

Regards,

Jan Karel Pieterse
Excel MVP
http://www.jkp-ads.com

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
Excel---how do i automate adding a suffix to text? Peter-NYC Excel Discussion (Misc queries) 1 January 29th 08 05:21 PM
Automate adding in a reference number if the adjacent cell contains text... mg[_2_] Excel Worksheet Functions 1 January 24th 08 01:16 AM
Double quotes bracketing text strings that include commas ExcelStudent Excel Discussion (Misc queries) 1 August 2nd 07 12:48 PM
8 team bracketing sheet Ryan Schwartz Excel Discussion (Misc queries) 1 February 13th 07 05:40 PM
Excel - Automate row width for merged cells with wrapped text Sweetiedaw Setting up and Configuration of Excel 0 September 7th 06 10:23 PM


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

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"