Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Selection of the range filled in

Hi,
I need a macro that can select a range.

It should always start in B3 and continue with the cells below until a blank
cell is met.

The selection should be used later for sorting or copying.



I hope someone can help.



Regards

Kaj Pedersen


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Selection of the range filled in

Kaj,

cRows= Cells(Rows.Count,"B").End(xlUp).Row-1
Range("B3:B"&cRows).Select

This searches from the bottom to the first encountered non-blank cell, so if
you have a blank in say row 20, and then data in row 21, it will include row
21. Reading your post literally, this may not be what you want.

--

HTH

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

"Kaj Pedersen" wrote in message
...
Hi,
I need a macro that can select a range.

It should always start in B3 and continue with the cells below until a

blank
cell is met.

The selection should be used later for sorting or copying.



I hope someone can help.



Regards

Kaj Pedersen




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,337
Default Selection of the range filled in

Why not just define the range
insertnamedefineput in a name such as rngB
in the refers to box type in
=offset($b$3,0,0,counta($B:$B),1)
now sort on [rngB]

"Kaj Pedersen" wrote in message
...
Hi,
I need a macro that can select a range.

It should always start in B3 and continue with the cells below until a

blank
cell is met.

The selection should be used later for sorting or copying.



I hope someone can help.



Regards

Kaj Pedersen




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Selection of the range filled in

Hi Bob,
Your suggestion was exactly what I wanted, except that I have not used -1 in
the first line.
Thank you.

Regards
Kaj Pedersen


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Selection of the range filled in

Kaj,

That's because I assumed something that you didn't say, that is you wanted
to stop at the last data row, not the first blank row. I should have made
that clear to you.

Glad it works for you.

Bob

"Kaj Pedersen" wrote in message
...
Hi Bob,
Your suggestion was exactly what I wanted, except that I have not used -1

in
the first line.
Thank you.

Regards
Kaj Pedersen






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Selection of the range filled in

Bob,
think you made a mistake with the -1: (mental glitch)


Range("B20").Value = 1
? cells(rows.Count,2).end(xlup).Row
20

It doesn't stop until it gets to the filled cell - you know that.

--
Regards,
Tom Ogilvy



Bob Phillips wrote in message
...
Kaj,

That's because I assumed something that you didn't say, that is you wanted
to stop at the last data row, not the first blank row. I should have made
that clear to you.

Glad it works for you.

Bob

"Kaj Pedersen" wrote in message
...
Hi Bob,
Your suggestion was exactly what I wanted, except that I have not

used -1
in
the first line.
Thank you.

Regards
Kaj Pedersen






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 620
Default Selection of the range filled in

Tom,

You're absolutely right. I (think that I) was getting confused with the next
free cell. So it wasn't making a maybe invalid assumption, just a simple
stupid error.

Things get far too damned complex, especially when you start analysing what
you did and why you did<VBG.

Think I'll just stick to drinking the wine, and be happy that the OPs get
what they want, especially when the figure it themselves.

Best Regards

Bob


"Tom Ogilvy" wrote in message
...
Bob,
think you made a mistake with the -1: (mental glitch)


Range("B20").Value = 1
? cells(rows.Count,2).end(xlup).Row
20

It doesn't stop until it gets to the filled cell - you know that.

--
Regards,
Tom Ogilvy



Bob Phillips wrote in message
...
Kaj,

That's because I assumed something that you didn't say, that is you

wanted
to stop at the last data row, not the first blank row. I should have

made
that clear to you.

Glad it works for you.

Bob

"Kaj Pedersen" wrote in message
...
Hi Bob,
Your suggestion was exactly what I wanted, except that I have not

used -1
in
the first line.
Thank you.

Regards
Kaj Pedersen








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
Count filled cells in range if they are one after the other lopina Excel Worksheet Functions 17 April 2nd 10 02:49 AM
The last filled cell in a range The Narcissist Excel Discussion (Misc queries) 6 February 8th 08 04:17 AM
Identifying a selection of a selection of a range swimfast Excel Worksheet Functions 1 March 1st 07 02:51 AM
how use range to bottom of filled cells? Ian Elliott Excel Worksheet Functions 1 November 14th 05 07:29 PM
Counting blank and filled cells within a range. greg7468 Excel Discussion (Misc queries) 3 June 28th 05 10:41 PM


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