Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 118
Default Cell formatting code

Hi All
The code below works fine.
But, as you can see it was from a recorded macro, apart from the first line.
Is it possible to make this code "cleaner" by removing excess code.
I have tried to make some changes but keep getting errors.
Any assistance would be appreciated.

Regards
Michael M

With range("E17:G" & lrow + 2)
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.Font.Size = 10
.NumberFormat = "#,##0.00"
End With
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Cell formatting code

One way:

With Range("E17:G" & lrow + 2)
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.Font.Size = 10
.NumberFormat = "#,##0.00"
With .Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With .Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
End With


In article ,
Michael M wrote:

Hi All
The code below works fine.
But, as you can see it was from a recorded macro, apart from the first line.
Is it possible to make this code "cleaner" by removing excess code.
I have tried to make some changes but keep getting errors.
Any assistance would be appreciated.

Regards
Michael M

With range("E17:G" & lrow + 2)
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.Font.Size = 10
.NumberFormat = "#,##0.00"
End With
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With

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
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
conditional formatting w/ more than 3 conditionas, color code to a different cell oldbarnes About this forum 0 May 24th 07 01:27 AM
Zip Code Formatting JWCrosby New Users to Excel 8 July 1st 06 11:17 AM
Zip Code Formatting weeshie73[_4_] Excel Programming 1 April 26th 06 06:09 PM
Formatting a cell in Excel, using pure VB code Jean Claude Excel Programming 4 October 2nd 03 05:41 PM


All times are GMT +1. The time now is 04:01 PM.

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"