Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 519
Default Highlite from A2 to Last Fred then to Column G

Hello from Steved

Using the Below to find the last name Fred in Col A I would like please to
have the cursor in Cell A2 then Highlite the Cells to the last Name Fred then
once found Highlite 7 colums to the right, so for example the last Fred may
be found in Cell A 47, so in this intance the highlighted cells would be A2:
G47 Thankyou.

Option Explicit
Sub myFind()

Dim FoundCell As Range
With ActiveSheet
With .Range("a:a")
Set FoundCell = .Cells.Find(what:="Fred", _
after:=.Cells(1), _
LookIn:=xlValues, _
lookat:=xlWhole, _
SearchOrder:=xlByRows, _
searchdirection:=xlPrevious, _
MatchCase:=False)
End With
End With

If FoundCell Is Nothing Then
MsgBox "Fred wasn't found!"
Else
Application.Goto FoundCell, scroll:=True
End If
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default Highlite from A2 to Last Fred then to Column G

Once you locate FoundCell, you should be able to run this line of code...

Worksheets("Sheet1").Range("A2:G" & FoundCell.Row).Select

in order to select the range you indicated.

Rick


"Steved" wrote in message
...
Hello from Steved

Using the Below to find the last name Fred in Col A I would like please to
have the cursor in Cell A2 then Highlite the Cells to the last Name Fred
then
once found Highlite 7 colums to the right, so for example the last Fred
may
be found in Cell A 47, so in this intance the highlighted cells would be
A2:
G47 Thankyou.

Option Explicit
Sub myFind()

Dim FoundCell As Range
With ActiveSheet
With .Range("a:a")
Set FoundCell = .Cells.Find(what:="Fred", _
after:=.Cells(1), _
LookIn:=xlValues, _
lookat:=xlWhole, _
SearchOrder:=xlByRows, _
searchdirection:=xlPrevious, _
MatchCase:=False)
End With
End With

If FoundCell Is Nothing Then
MsgBox "Fred wasn't found!"
Else
Application.Goto FoundCell, scroll:=True
End If
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default Highlite from A2 to Last Fred then to Column G

Sorry, test code accidentally left in... for your stated condition, the
statement should be...

ActiveSheet.Range("A2:G" & FoundCell.Row).Select

unless you extend the End With statement for the With ActiveSheet block to
encompass the statement, in which case you can leave the ActiveSheet off...

..Range("A2:G" & FoundCell.Row).Select

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
Once you locate FoundCell, you should be able to run this line of code...

Worksheets("Sheet1").Range("A2:G" & FoundCell.Row).Select

in order to select the range you indicated.

Rick


"Steved" wrote in message
...
Hello from Steved

Using the Below to find the last name Fred in Col A I would like please
to
have the cursor in Cell A2 then Highlite the Cells to the last Name Fred
then
once found Highlite 7 colums to the right, so for example the last Fred
may
be found in Cell A 47, so in this intance the highlighted cells would be
A2:
G47 Thankyou.

Option Explicit
Sub myFind()

Dim FoundCell As Range
With ActiveSheet
With .Range("a:a")
Set FoundCell = .Cells.Find(what:="Fred", _
after:=.Cells(1), _
LookIn:=xlValues, _
lookat:=xlWhole, _
SearchOrder:=xlByRows, _
searchdirection:=xlPrevious, _
MatchCase:=False)
End With
End With

If FoundCell Is Nothing Then
MsgBox "Fred wasn't found!"
Else
Application.Goto FoundCell, scroll:=True
End If
End Sub



  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 519
Default Highlite from A2 to Last Fred then to Column G

Hello from Steved

Thankyou

I put in your Script as show'n below it finds in this case Panmure but does
not select ( highlite ) the cells, please what have I've done wrong.

Thankyou.

Option Explicit
Sub myFind()

Dim FoundCell As Range
With ActiveSheet
With .Range("a:a")
Set FoundCell = .Cells.Find(what:="Panmure", _
after:=.Cells(1), _
LookIn:=xlValues, _
lookat:=xlWhole, _
SearchOrder:=xlByRows, _
searchdirection:=xlPrevious, _
MatchCase:=False)
End With
End With

If FoundCell Is Nothing Then
ActiveSheet.Range("A2:G" & FoundCell.Row).Select
Else
Application.Goto FoundCell, scroll:=True
End If
End Sub





"Rick Rothstein (MVP - VB)" wrote:

Sorry, test code accidentally left in... for your stated condition, the
statement should be...

ActiveSheet.Range("A2:G" & FoundCell.Row).Select

unless you extend the End With statement for the With ActiveSheet block to
encompass the statement, in which case you can leave the ActiveSheet off...

..Range("A2:G" & FoundCell.Row).Select

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
Once you locate FoundCell, you should be able to run this line of code...

Worksheets("Sheet1").Range("A2:G" & FoundCell.Row).Select

in order to select the range you indicated.

Rick


"Steved" wrote in message
...
Hello from Steved

Using the Below to find the last name Fred in Col A I would like please
to
have the cursor in Cell A2 then Highlite the Cells to the last Name Fred
then
once found Highlite 7 colums to the right, so for example the last Fred
may
be found in Cell A 47, so in this intance the highlighted cells would be
A2:
G47 Thankyou.

Option Explicit
Sub myFind()

Dim FoundCell As Range
With ActiveSheet
With .Range("a:a")
Set FoundCell = .Cells.Find(what:="Fred", _
after:=.Cells(1), _
LookIn:=xlValues, _
lookat:=xlWhole, _
SearchOrder:=xlByRows, _
searchdirection:=xlPrevious, _
MatchCase:=False)
End With
End With

If FoundCell Is Nothing Then
MsgBox "Fred wasn't found!"
Else
Application.Goto FoundCell, scroll:=True
End If
End Sub




  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default Highlite from A2 to Last Fred then to Column G

It looks like you put it in the wrong IF section... If FoundCell Is Nothing
Then means FoundCell has nothing in it... try putting it in the Else section
(and put whatever was originally in the first section back).

Rick


"Steved" wrote in message
...
Hello from Steved

Thankyou

I put in your Script as show'n below it finds in this case Panmure but
does
not select ( highlite ) the cells, please what have I've done wrong.

Thankyou.

Option Explicit
Sub myFind()

Dim FoundCell As Range
With ActiveSheet
With .Range("a:a")
Set FoundCell = .Cells.Find(what:="Panmure", _
after:=.Cells(1), _
LookIn:=xlValues, _
lookat:=xlWhole, _
SearchOrder:=xlByRows, _
searchdirection:=xlPrevious, _
MatchCase:=False)
End With
End With

If FoundCell Is Nothing Then
ActiveSheet.Range("A2:G" & FoundCell.Row).Select
Else
Application.Goto FoundCell, scroll:=True
End If
End Sub





"Rick Rothstein (MVP - VB)" wrote:

Sorry, test code accidentally left in... for your stated condition, the
statement should be...

ActiveSheet.Range("A2:G" & FoundCell.Row).Select

unless you extend the End With statement for the With ActiveSheet block
to
encompass the statement, in which case you can leave the ActiveSheet
off...

..Range("A2:G" & FoundCell.Row).Select

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
Once you locate FoundCell, you should be able to run this line of
code...

Worksheets("Sheet1").Range("A2:G" & FoundCell.Row).Select

in order to select the range you indicated.

Rick


"Steved" wrote in message
...
Hello from Steved

Using the Below to find the last name Fred in Col A I would like
please
to
have the cursor in Cell A2 then Highlite the Cells to the last Name
Fred
then
once found Highlite 7 colums to the right, so for example the last
Fred
may
be found in Cell A 47, so in this intance the highlighted cells would
be
A2:
G47 Thankyou.

Option Explicit
Sub myFind()

Dim FoundCell As Range
With ActiveSheet
With .Range("a:a")
Set FoundCell = .Cells.Find(what:="Fred", _
after:=.Cells(1), _
LookIn:=xlValues, _
lookat:=xlWhole, _
SearchOrder:=xlByRows, _
searchdirection:=xlPrevious, _
MatchCase:=False)
End With
End With

If FoundCell Is Nothing Then
MsgBox "Fred wasn't found!"
Else
Application.Goto FoundCell, scroll:=True
End If
End Sub







  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 519
Default Highlite from A2 to Last Fred then to Column G

Hello from Steved

Thankyou it does as you have instructed

Ok is it possible using excell 2007 do a Data Sort please on Col E

Thanks for yor time on my issue

"Rick Rothstein (MVP - VB)" wrote:

It looks like you put it in the wrong IF section... If FoundCell Is Nothing
Then means FoundCell has nothing in it... try putting it in the Else section
(and put whatever was originally in the first section back).

Rick


"Steved" wrote in message
...
Hello from Steved

Thankyou

I put in your Script as show'n below it finds in this case Panmure but
does
not select ( highlite ) the cells, please what have I've done wrong.

Thankyou.

Option Explicit
Sub myFind()

Dim FoundCell As Range
With ActiveSheet
With .Range("a:a")
Set FoundCell = .Cells.Find(what:="Panmure", _
after:=.Cells(1), _
LookIn:=xlValues, _
lookat:=xlWhole, _
SearchOrder:=xlByRows, _
searchdirection:=xlPrevious, _
MatchCase:=False)
End With
End With

If FoundCell Is Nothing Then
ActiveSheet.Range("A2:G" & FoundCell.Row).Select
Else
Application.Goto FoundCell, scroll:=True
End If
End Sub





"Rick Rothstein (MVP - VB)" wrote:

Sorry, test code accidentally left in... for your stated condition, the
statement should be...

ActiveSheet.Range("A2:G" & FoundCell.Row).Select

unless you extend the End With statement for the With ActiveSheet block
to
encompass the statement, in which case you can leave the ActiveSheet
off...

..Range("A2:G" & FoundCell.Row).Select

Rick


"Rick Rothstein (MVP - VB)" wrote in
message ...
Once you locate FoundCell, you should be able to run this line of
code...

Worksheets("Sheet1").Range("A2:G" & FoundCell.Row).Select

in order to select the range you indicated.

Rick


"Steved" wrote in message
...
Hello from Steved

Using the Below to find the last name Fred in Col A I would like
please
to
have the cursor in Cell A2 then Highlite the Cells to the last Name
Fred
then
once found Highlite 7 colums to the right, so for example the last
Fred
may
be found in Cell A 47, so in this intance the highlighted cells would
be
A2:
G47 Thankyou.

Option Explicit
Sub myFind()

Dim FoundCell As Range
With ActiveSheet
With .Range("a:a")
Set FoundCell = .Cells.Find(what:="Fred", _
after:=.Cells(1), _
LookIn:=xlValues, _
lookat:=xlWhole, _
SearchOrder:=xlByRows, _
searchdirection:=xlPrevious, _
MatchCase:=False)
End With
End With

If FoundCell Is Nothing Then
MsgBox "Fred wasn't found!"
Else
Application.Goto FoundCell, scroll:=True
End If
End Sub






  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
Default Highlite from A2 to Last Fred then to Column G

Ok is it possible using excell 2007 do a Data Sort please on Col E

Yes, but I am not sure why you would be having trouble with this. Highlight
your range, click on the Data tab and find the Sort icon in the toolbar that
is displayed (looks like a 4-cell table with A's and Z's in it.

Rick

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
find the last Fred and goto cell Steved Excel Worksheet Functions 6 October 11th 07 06:53 PM
How do you count number of times Fred Smith appears in a list Geoff Excel Discussion (Misc queries) 1 October 5th 07 04:58 PM
Are Fred Pryor Seminars good? [email protected] Excel Discussion (Misc queries) 10 November 15th 06 05:51 AM
I need help fred smith scats Excel Worksheet Functions 1 November 14th 06 04:32 AM
Highlite a row Red Excel Worksheet Functions 1 October 30th 04 10:52 PM


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