Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merge & Center Hotkey in Excel 2003

Status
Not open for further replies.

sc123

IS-IT--Management
Feb 13, 2002
89
0
0
US
Does anyone know the key for this?
Thanks!
SC
 
SC,

This is not a HOTKEY.

It's a Button on the Format ToolBar.

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
I know there is a button on the Format Toolbar or I would not know the function existed in the first place. There doesn't even seem to be a way to record a macro to accomplish this. Anyone else know of a hotkey?
 
Turn on the macro recorder, giving macro a HotKey.

Either

Hit the Merge & Center Button

or

Format/Cells - Alignment Tab - Horizontal: Center, Text Control: Check Metge Cells

Turn off the macro recorder

VOLA! :-0

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
That only works if I want to make C6-E6 merge every time I run the macro. I need a hotkey to trigger the merge & center for and cells that I have highlighted.
 
Post your code. My crystaal ball is a tad cloudy.

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
sc123,
You state that you want it to run on selected text, not on a specific range. You need to select your range first then start to record your macro, Not start the recording and then select your range.
This one I selected the range first, then clicked reocrd

Sub merge()
'
' merge Macro
' Macro recorded 7/10/2004 by Mbarron
'

'

With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
Selection.merge
End Sub

this one I clicked record first then selected the range.

Sub Merge2()
'
' Merge2 Macro
' Macro recorded 7/10/2004 by Mbarron
'

'

Range("E10:G10").Select

With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.MergeCells = False
End With
Selection.merge
End Sub




Mike
 
Duh!

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
As a rule of thumb, if you define the range in the macro, that range will stay. You can, of course, name a variable for the range and select the range with "InputBox".
 
My reference to "C6-E6" was merely an example of a range. I did not mean for you to think I meant that I always wanted to merge a pre-defined range, because that is exactly what I do not want to do. What I want to do is be able to highlight a row of cells anywhere in Excel and press a hotkey to merge and center those cells (just like bolding is CTRL-B, etc).
 
You NEVER posted your code...
Code:
Sub MergeCenter()
    With Selection
        .HorizontalAlignment = xlCenter
        .Merge
    End With
End Sub
:)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
Ah the programmer, always looking for the code! I actually didn't keep the macro I made after I saw that it only merged pre-defined rows and/or columns.
 
Almost always, recorded code must me modified to make it suitable and GENERAL.

In this case, I deleted any FORMATTING properties that were not desired. For instance, if you had already set the Vertical Alignment to CENTER for the Selection, you would not want it set to BOTTOM!

:)

Skip,

Want to get great answers to your Tek-Tips questions? Have a look at faq222-2244
 
Skip:
That code did nothing that I could see.
 
Strike that Skip, it worked! Thanks a bunch!!!
-SC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top