Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Brett
 
Posts: n/a
Default Removing parentheses

Not sure if this is the correct group. Please advise me if not.

What will a VBA macro look like that removes all parentheses from the first
column of an Excel worksheet and then sets the format for that column to
"general"?

Thanks,
Brett


  #2   Report Post  
Jason Morin
 
Posts: n/a
Default

You could record a macro under Tools Macros to do this,
or try this:

Sub DeleteParen()
Dim ws As Worksheet
Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
Set ws = ActiveSheet
With ws
Set rng1 = .Range("A:A")
Set rng2 = .UsedRange
End With
Set rng3 = Application.Intersect(rng1, rng2)
With rng3
.Replace What:="(", Replacement:="", LookAt:=xlPart
.Replace What:=")", Replacement:="", LookAt:=xlPart
End With
Range("A:A").NumberFormat = "General"
End Sub

---
HTH
Jason
Atlanta, GA



-----Original Message-----
Not sure if this is the correct group. Please advise me

if not.

What will a VBA macro look like that removes all

parentheses from the first
column of an Excel worksheet and then sets the format

for that column to
"general"?

Thanks,
Brett


.

  #3   Report Post  
Brett
 
Posts: n/a
Default

I like the code. Thanks.

I opened the VB Editor and pasted into spreadsheet1. I can save it as an
xls file. However, when I reopen Excel and do alt+F8, the Macro won't be
listed there. How do I have it listed it in the Macro section everytime I
open Excel on this machine?

Is there a way to create a keyboard shortcut to it?

Also, could you do a little line by line describing of what the is doing?

Thanks,
Brett

"Jason Morin" wrote in message
...
You could record a macro under Tools Macros to do this,
or try this:

Sub DeleteParen()
Dim ws As Worksheet
Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
Set ws = ActiveSheet
With ws
Set rng1 = .Range("A:A")
Set rng2 = .UsedRange
End With
Set rng3 = Application.Intersect(rng1, rng2)
With rng3
.Replace What:="(", Replacement:="", LookAt:=xlPart
.Replace What:=")", Replacement:="", LookAt:=xlPart
End With
Range("A:A").NumberFormat = "General"
End Sub

---
HTH
Jason
Atlanta, GA



-----Original Message-----
Not sure if this is the correct group. Please advise me

if not.

What will a VBA macro look like that removes all

parentheses from the first
column of an Excel worksheet and then sets the format

for that column to
"general"?

Thanks,
Brett


.



  #4   Report Post  
Dave Peterson
 
Posts: n/a
Default

If you save that workbook to your xlstart folder, then each time you start
excel, this workbook will be opened (and the macro will be available).

Lots of people use a workbook with the name of personal.xls for this kind of
thing.

And they'll even make it so that personal.xls workbook is hidden--so it doesn't
get in the way when you're swapping between workbooks.

Brett wrote:

I like the code. Thanks.

I opened the VB Editor and pasted into spreadsheet1. I can save it as an
xls file. However, when I reopen Excel and do alt+F8, the Macro won't be
listed there. How do I have it listed it in the Macro section everytime I
open Excel on this machine?

Is there a way to create a keyboard shortcut to it?

Also, could you do a little line by line describing of what the is doing?

Thanks,
Brett

"Jason Morin" wrote in message
...
You could record a macro under Tools Macros to do this,
or try this:

Sub DeleteParen()
Dim ws As Worksheet
Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
Set ws = ActiveSheet
With ws
Set rng1 = .Range("A:A")
Set rng2 = .UsedRange
End With
Set rng3 = Application.Intersect(rng1, rng2)
With rng3
.Replace What:="(", Replacement:="", LookAt:=xlPart
.Replace What:=")", Replacement:="", LookAt:=xlPart
End With
Range("A:A").NumberFormat = "General"
End Sub

---
HTH
Jason
Atlanta, GA



-----Original Message-----
Not sure if this is the correct group. Please advise me

if not.

What will a VBA macro look like that removes all

parentheses from the first
column of an Excel worksheet and then sets the format

for that column to
"general"?

Thanks,
Brett


.


--

Dave Peterson
  #5   Report Post  
Brett
 
Posts: n/a
Default

I saved the Personal.xls file to the xlsstart folder. It does load on
startup now and I can see the macro in Book1. However, when I run the macro
from Book1, nothing happens. I can see the macro is referencing the
Personal workbook in its name. Does the macro only work in the Personal
workbook rather than across work books?

Thanks,
Brett

"Dave Peterson" wrote in message
...
If you save that workbook to your xlstart folder, then each time you start
excel, this workbook will be opened (and the macro will be available).

Lots of people use a workbook with the name of personal.xls for this kind
of
thing.

And they'll even make it so that personal.xls workbook is hidden--so it
doesn't
get in the way when you're swapping between workbooks.

Brett wrote:

I like the code. Thanks.

I opened the VB Editor and pasted into spreadsheet1. I can save it as an
xls file. However, when I reopen Excel and do alt+F8, the Macro won't be
listed there. How do I have it listed it in the Macro section everytime
I
open Excel on this machine?

Is there a way to create a keyboard shortcut to it?

Also, could you do a little line by line describing of what the is doing?

Thanks,
Brett

"Jason Morin" wrote in message
...
You could record a macro under Tools Macros to do this,
or try this:

Sub DeleteParen()
Dim ws As Worksheet
Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
Set ws = ActiveSheet
With ws
Set rng1 = .Range("A:A")
Set rng2 = .UsedRange
End With
Set rng3 = Application.Intersect(rng1, rng2)
With rng3
.Replace What:="(", Replacement:="", LookAt:=xlPart
.Replace What:=")", Replacement:="", LookAt:=xlPart
End With
Range("A:A").NumberFormat = "General"
End Sub

---
HTH
Jason
Atlanta, GA



-----Original Message-----
Not sure if this is the correct group. Please advise me
if not.

What will a VBA macro look like that removes all
parentheses from the first
column of an Excel worksheet and then sets the format
for that column to
"general"?

Thanks,
Brett


.


--

Dave Peterson





  #6   Report Post  
Brett
 
Posts: n/a
Default

I saved the macro as personal.xls. It works fine as long as I'm in that
workbook. If I open a new workbook and call the macro, it doesn't work
right. For example, I enter this in column A

(301) 256-8965
3015489666

Then I format the column as special | Phone number. You'll notice the first
row (with literals) doesn't reformat. It will reformat if you are in the
personal workbook. Why is that?

Thanks,
Brett


"Jason Morin" wrote in message
...
You could record a macro under Tools Macros to do this,
or try this:

Sub DeleteParen()
Dim ws As Worksheet
Dim rng1 As Range
Dim rng2 As Range
Dim rng3 As Range
Set ws = ActiveSheet
With ws
Set rng1 = .Range("A:A")
Set rng2 = .UsedRange
End With
Set rng3 = Application.Intersect(rng1, rng2)
With rng3
.Replace What:="(", Replacement:="", LookAt:=xlPart
.Replace What:=")", Replacement:="", LookAt:=xlPart
End With
Range("A:A").NumberFormat = "General"
End Sub

---
HTH
Jason
Atlanta, GA



-----Original Message-----
Not sure if this is the correct group. Please advise me

if not.

What will a VBA macro look like that removes all

parentheses from the first
column of an Excel worksheet and then sets the format

for that column to
"general"?

Thanks,
Brett


.



  #7   Report Post  
Max
 
Posts: n/a
Default

This might also work ..

Put in B1:

=TEXT(TRIM(SUBSTITUTE(SUBSTITUTE(A1,"(",""),")","" )),"General")

Copy B1 down

Then do a copy on col B,
paste special as values to overwrite col A,
and delete col B

--
Rgds
Max
xl 97
---
GMT+8, 1° 22' N 103° 45' E
xdemechanik <atyahoo<dotcom
----
"Brett" wrote in message
...
Not sure if this is the correct group. Please advise me if not.

What will a VBA macro look like that removes all parentheses from the

first
column of an Excel worksheet and then sets the format for that column to
"general"?

Thanks,
Brett




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
Removing Module Protection Programatically Adam Excel Discussion (Misc queries) 8 April 17th 06 05:46 AM
Why cant you show negative numbers in parentheses? Bruce Excel Discussion (Misc queries) 5 December 6th 05 04:26 PM
How do I stop excel removing zeros? tomcat Excel Discussion (Misc queries) 2 January 21st 05 05:40 PM
Removing Hard Borders from Excel Spreadsheet Battery Dude Excel Worksheet Functions 1 January 11th 05 04:28 AM
Removing ' character from cells Don Excel Discussion (Misc queries) 5 December 21st 04 05:41 PM


All times are GMT +1. The time now is 12:25 AM.

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

About Us

"It's about Microsoft Excel"