Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Help - selecting range

Hi,

I have a set of data which starts at C22. there is data in the cells
around this, but I am only interested in selecting the range C22 and
all cells containing data to the right and cells containing data below
cell C22. I have used xltoright and xldown before, but can't seem to
get them to work together to select a multi column/row range. The
number of columns and rows of data does change.


hope you can help?

Matt
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Help - selecting range

Sub across_and_down()
Set r = Range("C22")
For i = 4 To Columns.Count
If IsEmpty(Cells(22, i).Value) Then
Else
Set r = Union(r, Cells(22, i))
End If
Next

For i = 23 To Rows.Count
If IsEmpty(Cells(i, "C").Value) Then
Else
Set r = Union(r, Cells(i, "C"))
End If
Next
r.Select
End Sub


This macro will first move across row 22 starting from C22 and pick up cells
with data. The macro will then move down column C from C22 and pick up cells
with data
--
Gary''s Student - gsnu2007g


"MJKelly" wrote:

Hi,

I have a set of data which starts at C22. there is data in the cells
around this, but I am only interested in selecting the range C22 and
all cells containing data to the right and cells containing data below
cell C22. I have used xltoright and xldown before, but can't seem to
get them to work together to select a multi column/row range. The
number of columns and rows of data does change.


hope you can help?

Matt

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help - selecting range

I seem to be reading your request differently than Gary''s Student did. I'm
assuming you have a blank column just to the right of your data and a blank
row just under your data and that you are looking to select all of your data
only (no matter what else lies on the other side of the blank column and
blank row. If that interpretation is correct, this code will make that
selection...

Sub SelectMyData()
With Worksheets("Sheet1").Range("C22")
Range(Cells(.Row, .Column), Cells(.End(xlDown).Row, _
.End(xlToRight).Column)).Select
End With
End Sub


Rick



"MJKelly" wrote in message
...
Hi,

I have a set of data which starts at C22. there is data in the cells
around this, but I am only interested in selecting the range C22 and
all cells containing data to the right and cells containing data below
cell C22. I have used xltoright and xldown before, but can't seem to
get them to work together to select a multi column/row range. The
number of columns and rows of data does change.


hope you can help?

Matt


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 range in list of range names depending on a cell informa Courreges Excel Discussion (Misc queries) 2 June 19th 06 10:59 AM
Selecting a sub range? James Cornthwaite Excel Programming 7 June 9th 06 07:54 PM
selecting a range jhahes[_12_] Excel Programming 1 July 5th 05 08:57 PM
Help please in selecting range dependent on another range MickJJ Excel Programming 2 January 10th 05 12:01 PM
Selecting a Range inside a range hcova Excel Programming 0 July 13th 04 03:26 PM


All times are GMT +1. The time now is 02:22 PM.

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"