PC Review


Reply
Thread Tools Rate Thread

Cell formatting code

 
 
=?Utf-8?B?TWljaGFlbCBN?=
Guest
Posts: n/a
 
      3rd Apr 2007
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 With Quote
 
 
 
 
JE McGimpsey
Guest
Posts: n/a
 
      3rd Apr 2007
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 <827B1E7E-3D42-4409-9AEF-(E-Mail Removed)>,
Michael M <(E-Mail Removed)> 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 With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Code to copy the formulae of one cell to all the cell in the rangewith the specific cell and columnnumber changing Options Yuvraj Microsoft Excel Misc 0 29th Jun 2009 11:20 AM
code for formatting like custom cell formatting in excel DawnTreader Microsoft Access Form Coding 12 12th Jul 2008 01:12 PM
Why excel cell color did not change after formatting and VBA code? =?Utf-8?B?Q2FzZXkgV29uZw==?= Microsoft Excel Discussion 7 8th Nov 2007 05:20 PM
Code to show if a cell has met conditional formatting =?Utf-8?B?Y2Ri?= Microsoft Excel Programming 6 5th Jul 2007 01:42 PM
Formatting a cell in Excel, using pure VB code J.E. McGimpsey Microsoft Excel Programming 4 2nd Oct 2003 05:41 PM


Features
 

Advertising
 

Newsgroups
 


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