VBA For Excel Formatting

I need VBA for eliminating Merged Fields, Wrapped Text, Borders, and Bold formatting for a Worksheet.  When I record the macro performing the tasks it creates a macro that is working with Cells, and it creates a macro that is too large for Excel.  Can anyone help me please?  Thanks.  - Tom
LVL 7
tomfarrarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Russell FoxDatabase DeveloperCommented:
Just start with Cells.Select to select the entire sheet:
Sub RemoveAllFormatting()
'
' RemoveAllFormatting Macro
'

'
    Cells.Select
    Selection.ClearFormats
    Range("A1").Select
End Sub

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tomfarrarAuthor Commented:
Yes, that worked nicely.  Thanks, Russell.
0
DougCommented:
Try this. Address only those formats you mentioned.

Sub ClrFrmttng()

Dim rng As Range

Set rng = Selection

With rng
    .WrapText = False
    .UnMerge
    .Font.Bold = False
    .Borders(xlDiagonalDown).LineStyle = xlNone
    .Borders(xlDiagonalUp).LineStyle = xlNone
    .Borders(xlEdgeLeft).LineStyle = xlNone
    .Borders(xlEdgeTop).LineStyle = xlNone
    .Borders(xlEdgeBottom).LineStyle = xlNone
    .Borders(xlEdgeRight).LineStyle = xlNone
    .Borders(xlInsideVertical).LineStyle = xlNone
    .Borders(xlInsideHorizontal).LineStyle = xlNone
End With

Set rng = Nothing

End Sub

Open in new window

1
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

tomfarrarAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for tomfarrar's comment #a41242171

for the following reason:

Thanks again, Russell.  I am trying to get a grip on the VBA.
0
DougCommented:
Note that there's a Clear button on the Home tab of the ribbon that will also do what Russell mentioned.
0
Russell FoxDatabase DeveloperCommented:
No problem, though if it worked for you you should accept an answer as correct rather than requesting a closure.
0
tomfarrarAuthor Commented:
Thanks, Doug, perhaps I could have used the 'button" when recording my macro.  Sometimes I wonder about myself.  

Russell, my apology.  How do I make that change.  Didn't realize that is what I did.
0
Russell FoxDatabase DeveloperCommented:
That's actually exactly what I did to generate that code: start recording, select all, press clear->formats, select A1, stop recording.

I think I just need to hit the "object" button now and someone will look at it. It's just better for people who might have the same question if they can find an accepted answer here. I suggest splitting points with @Doug.
0
tomfarrarAuthor Commented:
Your wish is my command, Russell.  I will split the points when I get the okay to do so.  Thanks to both of you.  - Tom
0
tomfarrarAuthor Commented:
Thanks again, All.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.