ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting a range of a Find object (https://www.excelbanter.com/excel-programming/406529-selecting-range-find-object.html)

Kigol

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:="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)


Kigol

Selecting a range of a Find object
 
Well I used testrng.offset to get to where I wanted in the column in
combination with the Range object to select multiple cells. But does
anyone know of a cleaner way to do this? Thanks.

Dave Peterson

Selecting a range of a Find object
 
Dim DestCell as range
dim testrng as range
set testrng = yourfindhere(...)

if testrng is nothing then
'do nothing
else
with activesheet
set destcell = .cells(.rows.count,testrng.column).end(xlup).offse t(1,0)
end with

something.copy _
destination:=destcell
end if



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:="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)


--

Dave Peterson

Kigol

Selecting a range of a Find object
 
On Feb 22, 2:20*pm, Dave Peterson wrote:
Dim DestCell as range
dim testrng as range
set testrng = yourfindhere(...)

if testrng is nothing then
* 'do nothing
else
* with activesheet
* * *set destcell = .cells(.rows.count,testrng.column).end(xlup).offse t(1,0)
* end with

* something.copy _
* * destination:=destcell
end if





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:="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)


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Cool thanks.


All times are GMT +1. The time now is 11:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com