Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / General Excel Questions / April 2008

Tip: Looking for answers? Try searching our database.

vb code question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stan - 24 Apr 2008 21:44 GMT
I have 3 columns that have data of which column A has the criteria I want to
search for.  Once found, I want to select columns A, B, and C that match the
search criteria ( in this case "7760").  

The code below allows me to find the criteria and select columns A, B, and C
although I don't know how to tell it to find all rows that match the criteria
in column A.  In other words, I don't know how to tell it to go to the last
row that has 7760 in column A.

If you can assist I would be more than greatful!  Many thanks!

Dim rng As Range
   Cells(1, 1).Select
   Set rng = Range("A1:IV65400").Find(What:="7760", _
       After:=ActiveCell, _
       LookIn:=xlFormulas, _
       LookAt:=xlPart, _
       SearchOrder:=xlByRows, _
       SearchDirection:=xlNext, _
       MatchCase:=False, _
       SearchFormat:=False)
   If Not rng Is Nothing Then
       ActiveCell.End(xlDown).Offset(0, 3).Select
   End If
Don Guillett - 24 Apr 2008 23:06 GMT
I just recorded this. Cleaned up version below it

Sub Macro9()
'
' Macro9 Macro
' Macro recorded 4/24/2008 by Donald B. Guillett
'

'
   Range("A1:C1").Select
   Selection.AutoFilter
   Selection.AutoFilter Field:=1, Criteria1:="7760"
End Sub

Sub Filterwhat()
Dim mynum As Long
mynum = 7760
Range("A1:C100").AutoFilter Field:=1, Criteria1:=mynum
End Sub
Sub unfilter()
Range("A1:C100").AutoFilter
End Sub
Signature

Don Guillett
Microsoft MVP Excel
SalesAid Software
dguillett1@austin.rr.com

>I have 3 columns that have data of which column A has the criteria I want
>to
[quoted text clipped - 25 lines]
>        ActiveCell.End(xlDown).Offset(0, 3).Select
>    End If
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.