Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How to find text in worksheet and get the address of this cell ?
My example: A B C D 1 x c 2 x c 3 x c 4 x c 5 y I'm interested to select range "A1":"XY" where the XY should be always before the y, so I need to find a text "y" and read the address of this cell and passed it to Range("A1":XY).select in this case it will be range ("A1":"B4") but below 1 - will be ("A1":"B3") ; 2 - will be ("A5":"B9") A B C D 1 x c 2 x c 3 x c 4 y 5 x c 6 x c 7 x c 8 x c 9 x c 10 y |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
sub SelectRanges
dim i as long Dim rng as Range Dim start as Range set start = Range("A1") do while cell(i,1) < "" if lcase(cells(i,2)) = "y" then set rng = range(Start, cells(i-1,2)) rng.select set start = cells(i-1,1) end if i = i + 1 Loop ' select the last set rng = rng(start,cells(i-1,2)) rng.Select End sub -- Regards, Tom Ogilvy "Palka" wrote in message om... How to find text in worksheet and get the address of this cell ? My example: A B C D 1 x c 2 x c 3 x c 4 x c 5 y I'm interested to select range "A1":"XY" where the XY should be always before the y, so I need to find a text "y" and read the address of this cell and passed it to Range("A1":XY).select in this case it will be range ("A1":"B4") but below 1 - will be ("A1":"B3") ; 2 - will be ("A5":"B9") A B C D 1 x c 2 x c 3 x c 4 y 5 x c 6 x c 7 x c 8 x c 9 x c 10 y |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Return Value from a Range (depends on input to determind month) | Excel Worksheet Functions | |||
Add Rows depends on the number in a cell | Excel Worksheet Functions | |||
How can change range to select active rows instead of :=Range("S10 | Excel Discussion (Misc queries) | |||
Select always same Rows range | Excel Discussion (Misc queries) | |||
How do I place Range text into a header? | Excel Worksheet Functions |