#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Art Art is offline
external usenet poster
 
Posts: 587
Default force alignment?

I know how to format a cell so the alignment is centered both vertically and
horizontally.

However, if a user copies/pastes text from, say, Microsoft Word into a cell
in Excel, it positiions it to the left at the bottom of the cell. Not a big
deal, really, but I would like for all of the cells to be centered
horizontally and vertically.

Is there a way to force a cell to align its contents centered, even if it is
copied and pasted from another document, rather than manually entered with a
cursor inside the cell? (Perhaps a macro could check a cell once the enter
key is pressed or the focus leaves a cell in some way?)

Thanks!
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default force alignment?

Art

The paste options button allows you to "match destination" formatting.

If you don't want to use that you can use VBA.

Try this event code which retains all cell formatting when something is
copy/pasted into it.

Cells must be pre-formatted to centered and centered as you state.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = myValue
.EnableEvents = True
.CutCopyMode = False
End With
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code".

Copy/paste the code into the module.

Operates only on the one sheet.

If you wanted for all sheets use this code which is to placed in
Thisworkbook module, not a sheet module.

Private Sub Workbook_SheetChange(ByVal Sh As _
Object, ByVal Target As Range)
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = myValue
.EnableEvents = True
.CutCopyMode = False
End With
End Sub


Gord Dibben MS Excel MVP



On Mon, 15 Mar 2010 15:09:01 -0700, Art
wrote:

I know how to format a cell so the alignment is centered both vertically and
horizontally.

However, if a user copies/pastes text from, say, Microsoft Word into a cell
in Excel, it positiions it to the left at the bottom of the cell. Not a big
deal, really, but I would like for all of the cells to be centered
horizontally and vertically.

Is there a way to force a cell to align its contents centered, even if it is
copied and pasted from another document, rather than manually entered with a
cursor inside the cell? (Perhaps a macro could check a cell once the enter
key is pressed or the focus leaves a cell in some way?)

Thanks!


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Art Art is offline
external usenet poster
 
Posts: 587
Default force alignment?

To start, I pasted the code just in the sheet. However, when I copied/pasted
text from Word then moved to another cell, it didn't keep the formatting. I
was very excited about this working...am I missing something?

Thanks for the work...and look forward to hearing back from you!!!




"Gord Dibben" wrote:

Art

The paste options button allows you to "match destination" formatting.

If you don't want to use that you can use VBA.

Try this event code which retains all cell formatting when something is
copy/pasted into it.

Cells must be pre-formatted to centered and centered as you state.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = myValue
.EnableEvents = True
.CutCopyMode = False
End With
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code".

Copy/paste the code into the module.

Operates only on the one sheet.

If you wanted for all sheets use this code which is to placed in
Thisworkbook module, not a sheet module.

Private Sub Workbook_SheetChange(ByVal Sh As _
Object, ByVal Target As Range)
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = myValue
.EnableEvents = True
.CutCopyMode = False
End With
End Sub


Gord Dibben MS Excel MVP



On Mon, 15 Mar 2010 15:09:01 -0700, Art
wrote:

I know how to format a cell so the alignment is centered both vertically and
horizontally.

However, if a user copies/pastes text from, say, Microsoft Word into a cell
in Excel, it positiions it to the left at the bottom of the cell. Not a big
deal, really, but I would like for all of the cells to be centered
horizontally and vertically.

Is there a way to force a cell to align its contents centered, even if it is
copied and pasted from another document, rather than manually entered with a
cursor inside the cell? (Perhaps a macro could check a cell once the enter
key is pressed or the focus leaves a cell in some way?)

Thanks!


.

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Art Art is offline
external usenet poster
 
Posts: 587
Default force alignment?

Does this matter:

When a user pastes text from Word into the cell in Excel, they aren't
double-clicking in the cell. They click/select the cell, then paste (usually
CTRL-V). I don't have a problem with formatting being maintained if the user
double-clicks in the cell first, but this doesn't usually happen.

Will the VBA you suggested work if users do not double-click in the cell
(giving them a cursor)?



"Gord Dibben" wrote:

Art

The paste options button allows you to "match destination" formatting.

If you don't want to use that you can use VBA.

Try this event code which retains all cell formatting when something is
copy/pasted into it.

Cells must be pre-formatted to centered and centered as you state.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = myValue
.EnableEvents = True
.CutCopyMode = False
End With
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code".

Copy/paste the code into the module.

Operates only on the one sheet.

If you wanted for all sheets use this code which is to placed in
Thisworkbook module, not a sheet module.

Private Sub Workbook_SheetChange(ByVal Sh As _
Object, ByVal Target As Range)
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = myValue
.EnableEvents = True
.CutCopyMode = False
End With
End Sub


Gord Dibben MS Excel MVP



On Mon, 15 Mar 2010 15:09:01 -0700, Art
wrote:

I know how to format a cell so the alignment is centered both vertically and
horizontally.

However, if a user copies/pastes text from, say, Microsoft Word into a cell
in Excel, it positiions it to the left at the bottom of the cell. Not a big
deal, really, but I would like for all of the cells to be centered
horizontally and vertically.

Is there a way to force a cell to align its contents centered, even if it is
copied and pasted from another document, rather than manually entered with a
cursor inside the cell? (Perhaps a macro could check a cell once the enter
key is pressed or the focus leaves a cell in some way?)

Thanks!


.

  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default force alignment?

I have tested by copying strings of text from a Word document.

Back to Excel and paste into a cell.

Alignment stayed as Center/Center as I had originally formatted.

What do you mean by "moved to another cell"?


Gord

On Tue, 16 Mar 2010 07:55:01 -0700, Art
wrote:

To start, I pasted the code just in the sheet. However, when I copied/pasted
text from Word then moved to another cell, it didn't keep the formatting. I
was very excited about this working...am I missing something?

Thanks for the work...and look forward to hearing back from you!!!




"Gord Dibben" wrote:

Art

The paste options button allows you to "match destination" formatting.

If you don't want to use that you can use VBA.

Try this event code which retains all cell formatting when something is
copy/pasted into it.

Cells must be pre-formatted to centered and centered as you state.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = myValue
.EnableEvents = True
.CutCopyMode = False
End With
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code".

Copy/paste the code into the module.

Operates only on the one sheet.

If you wanted for all sheets use this code which is to placed in
Thisworkbook module, not a sheet module.

Private Sub Workbook_SheetChange(ByVal Sh As _
Object, ByVal Target As Range)
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = myValue
.EnableEvents = True
.CutCopyMode = False
End With
End Sub


Gord Dibben MS Excel MVP



On Mon, 15 Mar 2010 15:09:01 -0700, Art
wrote:

I know how to format a cell so the alignment is centered both vertically and
horizontally.

However, if a user copies/pastes text from, say, Microsoft Word into a cell
in Excel, it positiions it to the left at the bottom of the cell. Not a big
deal, really, but I would like for all of the cells to be centered
horizontally and vertically.

Is there a way to force a cell to align its contents centered, even if it is
copied and pasted from another document, rather than manually entered with a
cursor inside the cell? (Perhaps a macro could check a cell once the enter
key is pressed or the focus leaves a cell in some way?)

Thanks!


.




  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default force alignment?

Double-clicking on the cell puts the user into edit mode and they are
essentially pasting into the formula bar.

Either method of pasting works for me.

I rarely use the double-click and paste.

I generally paste directly to the cell. CTRL + V or EditPaste or just hit
Paste button.


Gord


On Tue, 16 Mar 2010 07:58:04 -0700, Art
wrote:

Does this matter:

When a user pastes text from Word into the cell in Excel, they aren't
double-clicking in the cell. They click/select the cell, then paste (usually
CTRL-V). I don't have a problem with formatting being maintained if the user
double-clicks in the cell first, but this doesn't usually happen.

Will the VBA you suggested work if users do not double-click in the cell
(giving them a cursor)?



"Gord Dibben" wrote:

Art

The paste options button allows you to "match destination" formatting.

If you don't want to use that you can use VBA.

Try this event code which retains all cell formatting when something is
copy/pasted into it.

Cells must be pre-formatted to centered and centered as you state.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = myValue
.EnableEvents = True
.CutCopyMode = False
End With
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code".

Copy/paste the code into the module.

Operates only on the one sheet.

If you wanted for all sheets use this code which is to placed in
Thisworkbook module, not a sheet module.

Private Sub Workbook_SheetChange(ByVal Sh As _
Object, ByVal Target As Range)
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = myValue
.EnableEvents = True
.CutCopyMode = False
End With
End Sub


Gord Dibben MS Excel MVP



On Mon, 15 Mar 2010 15:09:01 -0700, Art
wrote:

I know how to format a cell so the alignment is centered both vertically and
horizontally.

However, if a user copies/pastes text from, say, Microsoft Word into a cell
in Excel, it positiions it to the left at the bottom of the cell. Not a big
deal, really, but I would like for all of the cells to be centered
horizontally and vertically.

Is there a way to force a cell to align its contents centered, even if it is
copied and pasted from another document, rather than manually entered with a
cursor inside the cell? (Perhaps a macro could check a cell once the enter
key is pressed or the focus leaves a cell in some way?)

Thanks!


.


  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Art Art is offline
external usenet poster
 
Posts: 587
Default force alignment?

Either use the TAB key or press the enter key.

"Gord Dibben" wrote:

I have tested by copying strings of text from a Word document.

Back to Excel and paste into a cell.

Alignment stayed as Center/Center as I had originally formatted.

What do you mean by "moved to another cell"?


Gord

On Tue, 16 Mar 2010 07:55:01 -0700, Art
wrote:

To start, I pasted the code just in the sheet. However, when I copied/pasted
text from Word then moved to another cell, it didn't keep the formatting. I
was very excited about this working...am I missing something?

Thanks for the work...and look forward to hearing back from you!!!




"Gord Dibben" wrote:

Art

The paste options button allows you to "match destination" formatting.

If you don't want to use that you can use VBA.

Try this event code which retains all cell formatting when something is
copy/pasted into it.

Cells must be pre-formatted to centered and centered as you state.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = myValue
.EnableEvents = True
.CutCopyMode = False
End With
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code".

Copy/paste the code into the module.

Operates only on the one sheet.

If you wanted for all sheets use this code which is to placed in
Thisworkbook module, not a sheet module.

Private Sub Workbook_SheetChange(ByVal Sh As _
Object, ByVal Target As Range)
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = myValue
.EnableEvents = True
.CutCopyMode = False
End With
End Sub


Gord Dibben MS Excel MVP



On Mon, 15 Mar 2010 15:09:01 -0700, Art
wrote:

I know how to format a cell so the alignment is centered both vertically and
horizontally.

However, if a user copies/pastes text from, say, Microsoft Word into a cell
in Excel, it positiions it to the left at the bottom of the cell. Not a big
deal, really, but I would like for all of the cells to be centered
horizontally and vertically.

Is there a way to force a cell to align its contents centered, even if it is
copied and pasted from another document, rather than manually entered with a
cursor inside the cell? (Perhaps a macro could check a cell once the enter
key is pressed or the focus leaves a cell in some way?)

Thanks!

.


.

  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 22,906
Default force alignment?

If you want to email me the workbook I'll have a look.

gorddibbATshawDOTca change the obvious.


Gord

On Tue, 16 Mar 2010 16:18:01 -0700, Art
wrote:

Either use the TAB key or press the enter key.

"Gord Dibben" wrote:

I have tested by copying strings of text from a Word document.

Back to Excel and paste into a cell.

Alignment stayed as Center/Center as I had originally formatted.

What do you mean by "moved to another cell"?


Gord

On Tue, 16 Mar 2010 07:55:01 -0700, Art
wrote:

To start, I pasted the code just in the sheet. However, when I copied/pasted
text from Word then moved to another cell, it didn't keep the formatting. I
was very excited about this working...am I missing something?

Thanks for the work...and look forward to hearing back from you!!!




"Gord Dibben" wrote:

Art

The paste options button allows you to "match destination" formatting.

If you don't want to use that you can use VBA.

Try this event code which retains all cell formatting when something is
copy/pasted into it.

Cells must be pre-formatted to centered and centered as you state.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = myValue
.EnableEvents = True
.CutCopyMode = False
End With
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code".

Copy/paste the code into the module.

Operates only on the one sheet.

If you wanted for all sheets use this code which is to placed in
Thisworkbook module, not a sheet module.

Private Sub Workbook_SheetChange(ByVal Sh As _
Object, ByVal Target As Range)
Dim myValue
With Application
.EnableEvents = False
myValue = Target.Value
.Undo
Target = myValue
.EnableEvents = True
.CutCopyMode = False
End With
End Sub


Gord Dibben MS Excel MVP



On Mon, 15 Mar 2010 15:09:01 -0700, Art
wrote:

I know how to format a cell so the alignment is centered both vertically and
horizontally.

However, if a user copies/pastes text from, say, Microsoft Word into a cell
in Excel, it positiions it to the left at the bottom of the cell. Not a big
deal, really, but I would like for all of the cells to be centered
horizontally and vertically.

Is there a way to force a cell to align its contents centered, even if it is
copied and pasted from another document, rather than manually entered with a
cursor inside the cell? (Perhaps a macro could check a cell once the enter
key is pressed or the focus leaves a cell in some way?)

Thanks!

.


.


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
In Cell alignment, how do I update the default vertical alignment How to update default cell alignment Setting up and Configuration of Excel 2 February 4th 09 02:25 PM
Right Alignment Paul Gauci New Users to Excel 0 August 18th 08 07:33 PM
Margin Alignment aloysius Excel Discussion (Misc queries) 0 October 8th 07 07:52 PM
Need some help with alignment havocdragon Excel Discussion (Misc queries) 1 August 27th 06 01:09 PM
Alignment Leah Excel Discussion (Misc queries) 0 November 22nd 05 06:36 PM


All times are GMT +1. The time now is 06:18 AM.

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"