Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default worksheet range qualifier

Are the last 2 statements equivalent?

Dim oReportSheet As Worksheet
oReportSheet = Worksheets.Add
oReportSheet.Range(Cells(1, 1), Cells(1,
7)).Columns.EntireColumn.AutoFit
Range(oReportSheet.Cells(1, 1), oReportSheet.Cells(1,
7)).Columns.EntireColumn.AutoFit

What if the oReportSheet sheet weren't active. Would that matter?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default worksheet range qualifier

On Dec 14, 2:11 pm, "
wrote:
Are the last 2 statements equivalent?

Dim oReportSheet As Worksheet
oReportSheet = Worksheets.Add
oReportSheet.Range(Cells(1, 1), Cells(1,
7)).Columns.EntireColumn.AutoFit
Range(oReportSheet.Cells(1, 1), oReportSheet.Cells(1,
7)).Columns.EntireColumn.AutoFit

What if the oReportSheet sheet weren't active. Would that matter?


They are if oReportSheet is active. So are

Range(Cells(1, 1), Cells(1, 7)).Columns.EntireColumn.AutoFit

and

Activesheet.Range(Cells(1, 1), Cells(1,
7)).Columns.EntireColumn.AutoFit

If oReportSheet is not active, or may not be, the neatest syntax to
use is

With oReportSheet
.Range(.Cells(1, 1), .Cells(1, 7)).Columns.EntireColumn.AutoFit
end With

note the dots before Range and Cells. you must fully qualify the range
reference with the sheet object.

regards
Paul


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default worksheet range qualifier

On Dec 14, 9:24 am, wrote:
On Dec 14, 2:11 pm, "
wrote:

Are the last 2 statements equivalent?


Dim oReportSheet As Worksheet
oReportSheet = Worksheets.Add
oReportSheet.Range(Cells(1, 1), Cells(1,
7)).Columns.EntireColumn.AutoFit
Range(oReportSheet.Cells(1, 1), oReportSheet.Cells(1,
7)).Columns.EntireColumn.AutoFit


What if the oReportSheet sheet weren't active. Would that matter?


They are if oReportSheet is active. So are

Range(Cells(1, 1), Cells(1, 7)).Columns.EntireColumn.AutoFit

and

Activesheet.Range(Cells(1, 1), Cells(1,
7)).Columns.EntireColumn.AutoFit

If oReportSheet is not active, or may not be, the neatest syntax to
use is

With oReportSheet
.Range(.Cells(1, 1), .Cells(1, 7)).Columns.EntireColumn.AutoFit
end With

note the dots before Range and Cells. you must fully qualify the range
reference with the sheet object.

regards
Paul


thanks, Paul
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
need qualifier statement Abbey Somebody Excel Worksheet Functions 5 May 17th 09 03:11 PM
Invalid Qualifier Stuart[_21_] Excel Programming 4 April 21st 05 03:07 PM
IF function using a dates as the qualifier.. Qaspec Excel Worksheet Functions 2 January 19th 05 09:27 PM
Invalid Qualifier??? Michael Vaughan Excel Programming 1 November 29th 04 11:46 AM


All times are GMT +1. The time now is 04:24 AM.

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"