Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default S1.Range("D65536").End(xlUp).Select

Hi,

Bob Phillips had brought up something interesting the
other day with a little humor. But I can't remember the
exact code.

With this code, S1.Range("D65536").End(xlUp).Select, how
can it be rewritten to use Rows.Count instead of 65536, as
suggested by Bob? I always don't have enough or too many
quotation marks when I try to put these kinds of things
together with the ampersands. For some reason, I'm
stuck. I usually figure it out, but I must be doing
something wrong.

The objective is to use Rows.Count in the event that
Microsoft changes the number of rows in Excel...seems like
a good exercise this morning as well. :)

This could be rewritten from this:

Dim S1 As Worksheet
Set S1 = Sheets(1)
S1.Range("D65536").End(xlUp).Select

to something like:

S1.Range(" & "D" & S1.Rows.Count & ").End(xlUp).Select

But with the correct number of quotation marks and
configuration to make it function properly.

Thanks, Rick
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 550
Default S1.Range("D65536").End(xlUp).Select

Rick,

S1.Range("D" & Rows.Count).End(xlUp).Select

John

"Rick" wrote in message
...
Hi,

Bob Phillips had brought up something interesting the
other day with a little humor. But I can't remember the
exact code.

With this code, S1.Range("D65536").End(xlUp).Select, how
can it be rewritten to use Rows.Count instead of 65536, as
suggested by Bob? I always don't have enough or too many
quotation marks when I try to put these kinds of things
together with the ampersands. For some reason, I'm
stuck. I usually figure it out, but I must be doing
something wrong.

The objective is to use Rows.Count in the event that
Microsoft changes the number of rows in Excel...seems like
a good exercise this morning as well. :)

This could be rewritten from this:

Dim S1 As Worksheet
Set S1 = Sheets(1)
S1.Range("D65536").End(xlUp).Select

to something like:

S1.Range(" & "D" & S1.Rows.Count & ").End(xlUp).Select

But with the correct number of quotation marks and
configuration to make it function properly.

Thanks, Rick



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default S1.Range("D65536").End(xlUp).Select

Rick,

A little background.

As John shows, you don't need any sheet reference, as Rows.Count will be a
constant value contained within Excel, the correct value dependent upon the
Excel version.So although you can use
S1.Rows.Count
it is just not necessary.

As well as future proofing, and past proofing your code, it's efficient as
it is using a pre-defined constant.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"John Wilson" wrote in message
...
Rick,

S1.Range("D" & Rows.Count).End(xlUp).Select

John

"Rick" wrote in message
...
Hi,

Bob Phillips had brought up something interesting the
other day with a little humor. But I can't remember the
exact code.

With this code, S1.Range("D65536").End(xlUp).Select, how
can it be rewritten to use Rows.Count instead of 65536, as
suggested by Bob? I always don't have enough or too many
quotation marks when I try to put these kinds of things
together with the ampersands. For some reason, I'm
stuck. I usually figure it out, but I must be doing
something wrong.

The objective is to use Rows.Count in the event that
Microsoft changes the number of rows in Excel...seems like
a good exercise this morning as well. :)

This could be rewritten from this:

Dim S1 As Worksheet
Set S1 = Sheets(1)
S1.Range("D65536").End(xlUp).Select

to something like:

S1.Range(" & "D" & S1.Rows.Count & ").End(xlUp).Select

But with the correct number of quotation marks and
configuration to make it function properly.

Thanks, Rick





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default S1.Range("D65536").End(xlUp).Select

Interesting...

To throw my 2c in about future proofing.
If Microsoft were ever to introduce 65536 rows, I believe it would be per
worksheet/workbook, not application level, for backward compatibility
reasons.
It's possible then that the ActiveSheet and the working sheet could have a
different number of rows.
Code relying on Rows.Count would error because, for example,
Cells(4294967296,1) causes overflow for older worksheets.

That said, I've heard no indication that the row restriction will ever
changed.
Personally, I never use a sheet reference.

Rob


"Bob Phillips" wrote in message
...
Rick,

A little background.

As John shows, you don't need any sheet reference, as Rows.Count will be a
constant value contained within Excel, the correct value dependent upon

the
Excel version.So although you can use
S1.Rows.Count
it is just not necessary.

As well as future proofing, and past proofing your code, it's efficient as
it is using a pre-defined constant.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"John Wilson" wrote in message
...
Rick,

S1.Range("D" & Rows.Count).End(xlUp).Select

John

"Rick" wrote in message
...
Hi,

Bob Phillips had brought up something interesting the
other day with a little humor. But I can't remember the
exact code.

With this code, S1.Range("D65536").End(xlUp).Select, how
can it be rewritten to use Rows.Count instead of 65536, as
suggested by Bob? I always don't have enough or too many
quotation marks when I try to put these kinds of things
together with the ampersands. For some reason, I'm
stuck. I usually figure it out, but I must be doing
something wrong.

The objective is to use Rows.Count in the event that
Microsoft changes the number of rows in Excel...seems like
a good exercise this morning as well. :)

This could be rewritten from this:

Dim S1 As Worksheet
Set S1 = Sheets(1)
S1.Range("D65536").End(xlUp).Select

to something like:

S1.Range(" & "D" & S1.Rows.Count & ").End(xlUp).Select

But with the correct number of quotation marks and
configuration to make it function properly.

Thanks, Rick









  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default S1.Range("D65536").End(xlUp).Select

Another point

Neither approach works if there is data in the last cell.


"Bob Phillips" wrote in message
...
Rick,

A little background.

As John shows, you don't need any sheet reference, as Rows.Count will be a
constant value contained within Excel, the correct value dependent upon

the
Excel version.So although you can use
S1.Rows.Count
it is just not necessary.

As well as future proofing, and past proofing your code, it's efficient as
it is using a pre-defined constant.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"John Wilson" wrote in message
...
Rick,

S1.Range("D" & Rows.Count).End(xlUp).Select

John

"Rick" wrote in message
...
Hi,

Bob Phillips had brought up something interesting the
other day with a little humor. But I can't remember the
exact code.

With this code, S1.Range("D65536").End(xlUp).Select, how
can it be rewritten to use Rows.Count instead of 65536, as
suggested by Bob? I always don't have enough or too many
quotation marks when I try to put these kinds of things
together with the ampersands. For some reason, I'm
stuck. I usually figure it out, but I must be doing
something wrong.

The objective is to use Rows.Count in the event that
Microsoft changes the number of rows in Excel...seems like
a good exercise this morning as well. :)

This could be rewritten from this:

Dim S1 As Worksheet
Set S1 = Sheets(1)
S1.Range("D65536").End(xlUp).Select

to something like:

S1.Range(" & "D" & S1.Rows.Count & ").End(xlUp).Select

But with the correct number of quotation marks and
configuration to make it function properly.

Thanks, Rick







  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 52
Default S1.Range("D65536").End(xlUp).Select

Hi,

Thanks for all your comments. I was unable to get back to
you all sooner, because somehow I couldn't reach this site
again until now. Everything was locked up for a while,
for some reason.

Again, thanks.

-----Original Message-----
Hi,

Bob Phillips had brought up something interesting the
other day with a little humor. But I can't remember the
exact code.

With this code, S1.Range("D65536").End(xlUp).Select, how
can it be rewritten to use Rows.Count instead of 65536,

as
suggested by Bob? I always don't have enough or too many
quotation marks when I try to put these kinds of things
together with the ampersands. For some reason, I'm
stuck. I usually figure it out, but I must be doing
something wrong.

The objective is to use Rows.Count in the event that
Microsoft changes the number of rows in Excel...seems

like
a good exercise this morning as well. :)

This could be rewritten from this:

Dim S1 As Worksheet
Set S1 = Sheets(1)
S1.Range("D65536").End(xlUp).Select

to something like:

S1.Range(" & "D" & S1.Rows.Count & ").End(xlUp).Select

But with the correct number of quotation marks and
configuration to make it function properly.

Thanks, Rick
.

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
"Select method of Range class failed" Error Ayo Excel Discussion (Misc queries) 3 September 2nd 08 07:58 PM
Using "=randbetween" to select a number from a range of cells a0xbjzz Excel Worksheet Functions 4 August 4th 07 07:47 PM
Run-time error "1004" Select method of range class failed Tallan Excel Discussion (Misc queries) 3 March 7th 07 05:22 PM
Question about "End(xlUp)" property Dave Peterson[_3_] Excel Programming 1 August 4th 03 04:24 AM
Question about "End(xlUp)" property Chip Pearson Excel Programming 0 August 4th 03 02:57 AM


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