ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   vb code question (https://www.excelbanter.com/excel-discussion-misc-queries/185026-vbulletin-code-question.html)

Stan

vb code question
 
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

vb code question
 
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
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Stan" wrote in message
...
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




All times are GMT +1. The time now is 09:02 PM.

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