Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Selecting a range of a Find object

I use Cells.Find to locate a column. How do I select a certain range
within the column of the found range?

'-------------------Here is the dumbed down version of the code:
Set testrng = Cells.Find(What:="Highbridge Selections",
After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole,
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not testrng Is Nothing Then
Selection.copy


I know this selects the whole column:

testrng.EntireColumn.Copy

I want to be able to do this:

Range(testrng.column & "65536").end(xlup).
(offset(1,0).copy '(or paste)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Selecting a range of a Find object

Hi Kigol,

I am not really sure what range you are trying to copy or paste. that is a
range or only one cell. Below is a couple of examples of copy which might
help. If not what you want then can you describe what range in relation to
the found cell that you are trying to copy.

There is really nothing wrong with using testRng.Column but I like to assign
the number to a variable because I find the code easier to follow. I also
like to use line breaks in long code like find and tabulate the parameters
because I think that is also easier to follow; especially if the code is not
finding what I expect it to find and I need to check the parameters which
have been set.


Sub test_select()
Dim testRng As Range
Dim lngColumn As Long

Set testRng = Cells.Find(What:="Highbridge Selections", _
After:=ActiveCell, _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)

lngColumn = testRng.Column

'The following line copies the cells from 1 below
'the found cell to the last cell in the column
'that contains data.

Range(testRng.Offset(1, 0), Cells(65536, lngColumn).End(xlUp)).Copy

'The following copies one cell only below the found cell
testRng.Offset(1, 0).Copy


'The following is same as first example but uses
'the total number of rows in the worksheet in lieu of 65536
Range(testRng.Offset(1, 0), Cells(Rows.Count, lngColumn).End(xlUp)).Copy

End Sub

--
Regards,

OssieMac


"Kigol" wrote:

I use Cells.Find to locate a column. How do I select a certain range
within the column of the found range?

'-------------------Here is the dumbed down version of the code:
Set testrng = Cells.Find(What:="Highbridge Selections",
After:=ActiveCell, LookIn:=xlFormulas, LookAt:=xlWhole,
SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False)
If Not testrng Is Nothing Then
Selection.copy


I know this selects the whole column:

testrng.EntireColumn.Copy

I want to be able to do this:

Range(testrng.column & "65536").end(xlup).
(offset(1,0).copy '(or paste)

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 last pasted object avi Excel Programming 1 April 21st 07 10:23 PM
Selecting Drawing Object By Name Zone Excel Programming 3 December 22nd 06 08:21 PM
Range Object with Find and Offset Ctal[_2_] Excel Programming 1 March 3rd 05 02:45 PM
Selecting object Ronbo Excel Programming 2 January 13th 05 12:06 PM
Selecting cells which do not meet a formatting criteria, and assigning a Range object to these. SuperJas Excel Programming 5 February 23rd 04 03:36 AM


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