View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
George Nicholson George Nicholson is offline
external usenet poster
 
Posts: 149
Default Can you help me figure out why my macro is running slowly?

**Aircode**:

Dim rng as Range

With Sheets(shtData)
Set rng = Union(.Range(.Cells(rowNum, colNum), _
.Cells(rowNum, colNum)), _
.Range(.Cells(rowNum+8, colNum),
.Cells(rowNum+10, colNum)))
End With

With rng
' as you have it for Selection, but make sure you only include those
properties that are actually being changed
' i.e., avoid re-setting properties that already have the properties you
want (as much as possible)
' The macro recorder (which looks like it might be the source of some of
your code) is notorious for redundant redundancy:
' change just one propery and it includes a complete list, which results
in a performance hit if left unedited
' (PrintSetup is the worst example of this, iirc) It seems you have
already edited this, but the point bears repeating.
End With

Set rng = Nothing
'*******

HTH

"Phil" wrote in message
oups.com...
Thanks for the quick response. In step 10 I use a lot of .Select.
What would be a better way to accomplish the following?

Sheets(shtData).Select
Union(Range(Cells(rowNum, colNum), _
Cells(rowNum, colNum)), _
Range(Cells(rowNum+8, colNum),
Cells(rowNum+10, colNum))).Select
With Selection
.Borders(xlEdgeLeft).LineStyle=xlContinuous
.Borders(xlEdgeLeft).ColorIndex=48
.Interior.ColorIndex=15
.Font.Name = "Arial"
.Font.Size = 9
End With