Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22
Default Macro code to center pasted data in a column

Using Excel 2003, I have to add data to a spreadsheet throughout the data by
pasting data from a query. Is the some code to center data in a column
and/or right or left justify as well? I am a novice macro coder so all help
is greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Macro code to center pasted data in a column

Have you tried recording a macro while doing manually. Then clean up

sub centercol
Columns("E:F").horizontalAlignment = xlCenter
end sub

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 7/9/2007 by Donald B. Guillett
'

'
Columns("E:F").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Rich K." wrote in message
...
Using Excel 2003, I have to add data to a spreadsheet throughout the data
by
pasting data from a query. Is the some code to center data in a column
and/or right or left justify as well? I am a novice macro coder so all
help
is greatly appreciated.


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22
Default Macro code to center pasted data in a column

Thanks - that's what I did - the only problem I had with centering the column
was that it was a shared workbook. Once I took that off, works great,
Thanks for the tips and help


"Don Guillett" wrote:

Have you tried recording a macro while doing manually. Then clean up

sub centercol
Columns("E:F").horizontalAlignment = xlCenter
end sub

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 7/9/2007 by Donald B. Guillett
'

'
Columns("E:F").Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End Sub
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Rich K." wrote in message
...
Using Excel 2003, I have to add data to a spreadsheet throughout the data
by
pasting data from a query. Is the some code to center data in a column
and/or right or left justify as well? I am a novice macro coder so all
help
is greatly appreciated.



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
Getting macro to run with pasted function Glenn New Users to Excel 2 May 28th 07 04:24 PM
Transposing a pasted link row into a column Eden397 Excel Discussion (Misc queries) 3 May 25th 07 09:40 PM
pasted column splits at spaces jenn Excel Worksheet Functions 1 September 26th 06 06:34 PM
Macro code to autosum a dynamic length column SlowPoke Excel Discussion (Misc queries) 3 March 31st 06 11:48 PM
Prevent Hidden Column data from being copied/pasted? Jugglertwo Excel Discussion (Misc queries) 2 April 9th 05 12:45 PM


All times are GMT +1. The time now is 02:38 PM.

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"