Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Range statemeny query

Within I procedure I have come across a range statment which I cannot work out how it does
what it does and I would really like to understnd it.

Range("J2:J" & r)

If for example the value of r is 10, this range will return the range J2:J9, which is what
it is supposed to do, I know, but is 9 cells and I cannot see how it arrives at this.
They say he who asks a question is only ignorant for as long as it takes to hear the
answer to the question but he who doesn't ask a question is ignorant forever. Well I admit
to being ignorant at the moment but I would be grateful if someone could alleviate this
condition.

Graham
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 789
Default Range statemeny query

Hi
If r = 10 this will give you Range("J2:J10"). So r MUST be 9.
The question is now "Why is r = 9"?

regards
Paul

On Jul 3, 11:18*am, Graham H wrote:
Within I procedure I have come across a range statment which I cannot work out how it does
what it does and I would really like to understnd it.

Range("J2:J" & r)

If for example the value of r is 10, this range will return the range J2:J9, which is what
it is supposed to do, I know, but is 9 cells *and I cannot see how it arrives at this.
They say he who asks a question is only ignorant for as long as it takes to hear the
answer to the question but he who doesn't ask a question is ignorant forever. Well I admit
to being ignorant at the moment but I would be grateful if someone could alleviate this
condition.

Graham


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Range statemeny query

Paul,
I am hesitant to disagree but I ran the following part procedure

Dim r As Integer
Dim ws1 As Worksheet
Set ws1 = Sheets("Sheet1")
ws1.Columns("L:L").AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Range("J1"), Unique:=True
r = Cells(Rows.Count, "J").End(xlUp).Row
MsgBox r
Range("j2:J" & r).Select

and I can assure you that r was returned as 10 in the message box and the range selected
was J2:J9.
It could be me missing something simple which would not be unusual.

Graham

wrote:
Hi
If r = 10 this will give you Range("J2:J10"). So r MUST be 9.
The question is now "Why is r = 9"?

regards
Paul

On Jul 3, 11:18 am, Graham H wrote:
Within I procedure I have come across a range statment which I cannot work out how it does
what it does and I would really like to understnd it.

Range("J2:J" & r)

If for example the value of r is 10, this range will return the range J2:J9, which is what
it is supposed to do, I know, but is 9 cells and I cannot see how it arrives at this.
They say he who asks a question is only ignorant for as long as it takes to hear the
answer to the question but he who doesn't ask a question is ignorant forever. Well I admit
to being ignorant at the moment but I would be grateful if someone could alleviate this
condition.

Graham


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Range statemeny query

Maybe J2:J10 was selected--but row 10 was hidden by the filtering. So you
couldn't see that hidden selected cell (J10).



Graham H wrote:

Paul,
I am hesitant to disagree but I ran the following part procedure

Dim r As Integer
Dim ws1 As Worksheet
Set ws1 = Sheets("Sheet1")
ws1.Columns("L:L").AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Range("J1"), Unique:=True
r = Cells(Rows.Count, "J").End(xlUp).Row
MsgBox r
Range("j2:J" & r).Select

and I can assure you that r was returned as 10 in the message box and the range selected
was J2:J9.
It could be me missing something simple which would not be unusual.

Graham

wrote:
Hi
If r = 10 this will give you Range("J2:J10"). So r MUST be 9.
The question is now "Why is r = 9"?

regards
Paul

On Jul 3, 11:18 am, Graham H wrote:
Within I procedure I have come across a range statment which I cannot work out how it does
what it does and I would really like to understnd it.

Range("J2:J" & r)

If for example the value of r is 10, this range will return the range J2:J9, which is what
it is supposed to do, I know, but is 9 cells and I cannot see how it arrives at this.
They say he who asks a question is only ignorant for as long as it takes to hear the
answer to the question but he who doesn't ask a question is ignorant forever. Well I admit
to being ignorant at the moment but I would be grateful if someone could alleviate this
condition.

Graham



--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Range statemeny query

Column L and Column J each have the same heading so when r is run it returns 10 which is
correct for the data plus the header row in column J. Thus there is one header row and 9
rows of data, the 9 rows of data being returned by the range select statement but not
including the header row. I know I am probably being thick but I just couldn't see why it
returned that with r being 10. J2:J10 were selected it was just a range definition I was
not familiar with. Don't waste any more time on it, it works so I will leave it alone.
Many thanks.

Graham

Dave Peterson wrote:
Maybe J2:J10 was selected--but row 10 was hidden by the filtering. So you
couldn't see that hidden selected cell (J10).



Graham H wrote:
Paul,
I am hesitant to disagree but I ran the following part procedure

Dim r As Integer
Dim ws1 As Worksheet
Set ws1 = Sheets("Sheet1")
ws1.Columns("L:L").AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Range("J1"), Unique:=True
r = Cells(Rows.Count, "J").End(xlUp).Row
MsgBox r
Range("j2:J" & r).Select

and I can assure you that r was returned as 10 in the message box and the range selected
was J2:J9.
It could be me missing something simple which would not be unusual.

Graham

wrote:
Hi
If r = 10 this will give you Range("J2:J10"). So r MUST be 9.
The question is now "Why is r = 9"?

regards
Paul

On Jul 3, 11:18 am, Graham H wrote:
Within I procedure I have come across a range statment which I cannot work out how it does
what it does and I would really like to understnd it.

Range("J2:J" & r)

If for example the value of r is 10, this range will return the range J2:J9, which is what
it is supposed to do, I know, but is 9 cells and I cannot see how it arrives at this.
They say he who asks a question is only ignorant for as long as it takes to hear the
answer to the question but he who doesn't ask a question is ignorant forever. Well I admit
to being ignorant at the moment but I would be grateful if someone could alleviate this
condition.

Graham




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 56
Default Range statemeny query

Sorry, definiately ignorant but in a different way. Yes, columns and row 10!!
Aplologies

Graham

Graham H wrote:
Column L and Column J each have the same heading so when r is run it
returns 10 which is correct for the data plus the header row in column
J. Thus there is one header row and 9 rows of data, the 9 rows of data
being returned by the range select statement but not including the
header row. I know I am probably being thick but I just couldn't see why
it returned that with r being 10. J2:J10 were selected it was just a
range definition I was not familiar with. Don't waste any more time on
it, it works so I will leave it alone. Many thanks.

Graham

Dave Peterson wrote:
Maybe J2:J10 was selected--but row 10 was hidden by the filtering. So
you
couldn't see that hidden selected cell (J10).



Graham H wrote:
Paul,
I am hesitant to disagree but I ran the following part procedure

Dim r As Integer
Dim ws1 As Worksheet
Set ws1 = Sheets("Sheet1")
ws1.Columns("L:L").AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=Range("J1"), Unique:=True
r = Cells(Rows.Count, "J").End(xlUp).Row
MsgBox r
Range("j2:J" & r).Select

and I can assure you that r was returned as 10 in the message box and
the range selected
was J2:J9.
It could be me missing something simple which would not be unusual.

Graham

wrote:
Hi
If r = 10 this will give you Range("J2:J10"). So r MUST be 9.
The question is now "Why is r = 9"?

regards
Paul

On Jul 3, 11:18 am, Graham H wrote:
Within I procedure I have come across a range statment which I
cannot work out how it does
what it does and I would really like to understnd it.

Range("J2:J" & r)

If for example the value of r is 10, this range will return the
range J2:J9, which is what
it is supposed to do, I know, but is 9 cells and I cannot see how
it arrives at this.
They say he who asks a question is only ignorant for as long as it
takes to hear the
answer to the question but he who doesn't ask a question is
ignorant forever. Well I admit
to being ignorant at the moment but I would be grateful if someone
could alleviate this
condition.

Graham


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
Used range and SQL query Laurent[_2_] Excel Programming 5 October 29th 07 06:09 AM
Searching a range with MS Query dsb Excel Worksheet Functions 3 November 1st 06 11:04 PM
Range.Insert query [email protected] Excel Programming 1 September 6th 05 12:37 PM
How update range after web query? Chris Shearer Cooper Excel Programming 2 May 10th 04 10:15 PM
Finding the query range Belinda Excel Programming 2 February 13th 04 01:42 PM


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