LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Code won't work?

The science behind the With...End With structure is pretty simple:

1) The "." is used as shorthand for whatever follows the With, so


With Worksheets("Sheet1")
.Range("J2", .Range("J2").End(xlDown)).Copy
End With

is shorter, and perhaps faster to write than

Worksheets("Sheet1").Range("J2", _
Worksheets("Sheet1").Range("J2").End(xlDown)).Copy

2) In the second example, the Worksheets("Sheet1") reference has to
be resolved twice. Using With...End With, the worksheets("Sheet1")
reference is only resolved once. Resolving object (Workbook,
Worksheet, Range, etc.) references is very time and resource
consuming, so the With...End With structure is also more efficient
any time you have more than one reference to an object.


In article ,
"Joe 90" wrote:

Your extra "dots" worked a treat, and this will help me enormously with my
coding. just wish I properly understood the science behind it, although I
see what you say about the second range not being qualified.

 
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
Why does this code not work? rk0909 Excel Discussion (Misc queries) 12 September 4th 08 10:42 PM
Why this code is not work? Error code when select worksheet Excel Worksheet Functions 4 December 4th 07 12:51 AM
Why my code do not work : - ( keepitcool Excel Programming 5 September 5th 03 06:28 PM
Why my code do not work : - ( Tom Ogilvy Excel Programming 1 August 31st 03 04:53 PM
Why my code do not work : - ( Bob Phillips[_5_] Excel Programming 0 August 31st 03 01:27 PM


All times are GMT +1. The time now is 07:58 AM.

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"