Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Luc Luc is offline
external usenet poster
 
Posts: 23
Default Selecting a range of cells, how to ?

Hello,

I have a problem with selecting cells.

The selection allways goes from column A to M.
The number of rows starts allways from A 11, to the LAST CELL in column A
which contains a number
So the column range is fix, and the row range is variable.

For example :
It can be A11 to M24
or A11 to M5
or A11 to M11 (this is only 1 row)

What code should i use in the macro ?

Thanxx

Luc

--------------------------------------------------------------------------------
Mijn Postvak In wordt beschermd door SPAMfighter
301 spam-mails zijn er tot op heden geblokkeerd.
Download de gratis SPAMfighter vandaag nog!


  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 120
Default Selecting a range of cells, how to ?

Assuming that there are no gaps between numbers in column A then this
will work:

Public Sub selectStuff()
Dim ws As Worksheet
Set ws = ActiveSheet
if not ws.range("A12") = "" then
ws.Range("A11", ws.Cells(ws.Range("A11").End(xlDown).Row,
13)).Select
else
ws.range("A11:M11").select
end if
End Sub

' ws.Range("A11").End(xlDown).Row
' gets the row number of the last number before a space moving
downward from A11.
' However if A12 is blank then it would go to row 65536, therefore the
if statement

Cheers,
Jason Lepack

On Feb 23, 2:03 pm, "Luc" wrote:
Hello,

I have a problem with selecting cells.

The selection allways goes from column A to M.
The number of rows starts allways from A 11, to the LAST CELL in column A
which contains a number
So the column range is fix, and the row range is variable.

For example :
It can be A11 to M24
or A11 to M5
or A11 to M11 (this is only 1 row)

What code should i use in the macro ?

Thanxx

Luc

---------------------------------------------------------------------------*-----
Mijn Postvak In wordt beschermd door SPAMfighter
301 spam-mails zijn er tot op heden geblokkeerd.
Download de gratis SPAMfighter vandaag nog!



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7,247
Default Selecting a range of cells, how to ?

Try code like the following:

Dim LastRow As Long
With ActiveSheet
LastRow = Application.WorksheetFunction.Max(11, _
.Cells(Rows.Count, "A").End(xlUp).Row)
..Range(.Cells(11, "A"), .Cells(LastRow, "M")).Select
End With


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"Luc" wrote in message
...
Hello,

I have a problem with selecting cells.

The selection allways goes from column A to M.
The number of rows starts allways from A 11, to the LAST CELL in column A
which contains a number
So the column range is fix, and the row range is variable.

For example :
It can be A11 to M24
or A11 to M5
or A11 to M11 (this is only 1 row)

What code should i use in the macro ?

Thanxx

Luc

--------------------------------------------------------------------------------
Mijn Postvak In wordt beschermd door SPAMfighter
301 spam-mails zijn er tot op heden geblokkeerd.
Download de gratis SPAMfighter vandaag nog!



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
Selecting the correct number from a range of cells pajones via OfficeKB.com Excel Worksheet Functions 4 September 18th 06 04:04 PM
Selecting range in list of range names depending on a cell informa Courreges Excel Discussion (Misc queries) 2 June 19th 06 10:59 AM
Range selecting cells Alec H Excel Discussion (Misc queries) 2 March 14th 06 01:36 PM
Selecting a Range SJT Excel Discussion (Misc queries) 2 March 8th 06 07:30 PM
how to combine cells by selecting range? SPIRIT New Users to Excel 3 August 20th 05 10:40 AM


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