Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Auto select rows

I am using the following code to find "mySite1" which is always in column A.

Cells.Find(What:=mySite1, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

Once "mySite1" is found, I need the code to highlight from the selected,
found cell, including that cell, over to the right for a total of 22 cells.
So for example, if my code finds "mySite1" at A5, I need the code to
highlight A5 to V5. If my code finds "mySite1" at A7, I need the code to
highlight A7 to V7, 22 cells total.
Because "mySite1" can be on a different row from one report to another, I
can not specify the actual cells, ie A5:V5.

I tried using this code after "mySite1" is found but it does not work if any
cells between column A & V are blank even if I use the code multiple times.

Range(Selection, Selection.End(xlToRight)).Select

How can I write code to select a number of cells without specifying cells
like A5:V5?
I need to find "mySite1" then highlight from the found cell in column A to
column V same row # as the found cell.

Any help is appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Auto select rows

use something like this, but you'll have to change some of the code because i
don't have the formula you use. i just used the line mysite1 = "test1" to test
this.


Sub test()
Dim ws As Worksheet
Dim mysite1 As String
Dim rngfound As Range
Set ws = Worksheets("Sheet1")
mysite1 = "test1"
With ws.Columns("A:A")
Set rngfound = .Find(What:=mysite1, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not rngfound Is Nothing Then
ws.Range("A" & rngfound.Row & ":V" & rngfound.Row).Interior.ColorIndex =
17
End If
End With
End Sub

--


Gary


"SJW_OST" wrote in message
...
I am using the following code to find "mySite1" which is always in column A.

Cells.Find(What:=mySite1, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

Once "mySite1" is found, I need the code to highlight from the selected,
found cell, including that cell, over to the right for a total of 22 cells.
So for example, if my code finds "mySite1" at A5, I need the code to
highlight A5 to V5. If my code finds "mySite1" at A7, I need the code to
highlight A7 to V7, 22 cells total.
Because "mySite1" can be on a different row from one report to another, I
can not specify the actual cells, ie A5:V5.

I tried using this code after "mySite1" is found but it does not work if any
cells between column A & V are blank even if I use the code multiple times.

Range(Selection, Selection.End(xlToRight)).Select

How can I write code to select a number of cells without specifying cells
like A5:V5?
I need to find "mySite1" then highlight from the found cell in column A to
column V same row # as the found cell.

Any help is appreciated.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Auto select rows

You are great! Thank you very much.
I just needed to tweek 1 part. I mis-stated myself, I needed the code to
select the cells instead of highlight. I made that change and it works great.
Thank you!

"Gary Keramidas" wrote:

use something like this, but you'll have to change some of the code because i
don't have the formula you use. i just used the line mysite1 = "test1" to test
this.


Sub test()
Dim ws As Worksheet
Dim mysite1 As String
Dim rngfound As Range
Set ws = Worksheets("Sheet1")
mysite1 = "test1"
With ws.Columns("A:A")
Set rngfound = .Find(What:=mysite1, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not rngfound Is Nothing Then
ws.Range("A" & rngfound.Row & ":V" & rngfound.Row).Interior.ColorIndex =
17
End If
End With
End Sub

--


Gary


"SJW_OST" wrote in message
...
I am using the following code to find "mySite1" which is always in column A.

Cells.Find(What:=mySite1, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate

Once "mySite1" is found, I need the code to highlight from the selected,
found cell, including that cell, over to the right for a total of 22 cells.
So for example, if my code finds "mySite1" at A5, I need the code to
highlight A5 to V5. If my code finds "mySite1" at A7, I need the code to
highlight A7 to V7, 22 cells total.
Because "mySite1" can be on a different row from one report to another, I
can not specify the actual cells, ie A5:V5.

I tried using this code after "mySite1" is found but it does not work if any
cells between column A & V are blank even if I use the code multiple times.

Range(Selection, Selection.End(xlToRight)).Select

How can I write code to select a number of cells without specifying cells
like A5:V5?
I need to find "mySite1" then highlight from the found cell in column A to
column V same row # as the found cell.

Any help is appreciated.




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
How can i randomly select 780 rows from 4000 rows of data bbb Excel Worksheet Functions 2 July 6th 07 08:21 PM
Auto Number the Rows of Auto Filter Result ashish128 Excel Discussion (Misc queries) 3 April 29th 07 06:41 PM
select block of rows w/data between blank rows Janna Excel Programming 6 February 13th 05 02:45 AM
Unable to select rows in the repeat rows on top option Noppie Excel Discussion (Misc queries) 2 December 28th 04 03:17 PM
Auto filling a select # of rows M Rodas Excel Programming 1 March 6th 04 05:41 AM


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