LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Using With to speed up macro

While you've already got the solution to speed things up, I get the
impression that you don't really understand what With does:

With is not used to repeat code frequently but to repeatedly work with
the same area of your sheet. And since it doesn't use select and / or
activate it actually does speed up things tremendously, exactly for
the reasons given in the other post.

To give an example of how it's used:

With Range("Range")
' don't forget the period before Offset
.Offset(Count + 1).Value = xxx
.Offset(Count + 2).Value = yyy
' or simply make a change to the range itself
.Value = zzz
With .Font
.ColorIndex = 2
.Bold = True
End With
.Borders(xlEdgeBottom).LineStyle = xlDouble
End With

Leo

On Mon, 29 Dec 2003 14:31:07 -0800, Wesley
wrote:

I am trying to speed up my macro by using With, but the With doesn't seem to be working. Can someone give me an example of how to use With with my code? I have the following chunk of code that repeats for different variables.

If var1 = 1 Then
Range("Range").Offset(Count + 1, 0).Select
Selection.Copy
ActiveCell.Offset(0, 1).Activate
Workbooks(Book1).Activate
ActiveCell.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
End If
Workbooks(Book1).Activate
ActiveCell.Offset(1, 0).Activate
Workbooks(Book2).Activate

Thanks for the help,
Wesley


 
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
Speed up macro nc Excel Discussion (Misc queries) 2 November 23rd 06 02:10 PM
Help, need to speed up this macro retseort Excel Discussion (Misc queries) 3 January 12th 06 12:33 PM
Speed up macro rn Excel Discussion (Misc queries) 3 February 21st 05 01:25 PM
Speed-up macro Thomas[_7_] Excel Programming 2 October 2nd 03 05:55 AM
MACRO Speed? Jim[_25_] Excel Programming 2 September 15th 03 03:50 PM


All times are GMT +1. The time now is 09:59 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"