Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Find and display rows with criteria

I need some help writing a macro that would prompt the user for a value,
search the active worksheet and display all records that contain the value
input in the inputbox.

Thank you for your help.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Find and display rows with criteria

Sub billy()
Dim r As Range
v = Application.InputBox("Enter value: ", Type:=1)

For Each r In ActiveSheet.UsedRange
If r.Value = v Then
MsgBox (r.Address)
End If
Next
End Sub

The user enters a number and the sub displays all the records (addresses)
that contain that number.
--
Gary''s Student


"Billy B" wrote:

I need some help writing a macro that would prompt the user for a value,
search the active worksheet and display all records that contain the value
input in the inputbox.

Thank you for your help.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Find and display rows with criteria

I was really looking to do something more like a filter. If I entered IT32 in
the inputbox, display the entire row if any cell in that row contains IT32.
Thanks again.

"Gary''s Student" wrote:

Sub billy()
Dim r As Range
v = Application.InputBox("Enter value: ", Type:=1)

For Each r In ActiveSheet.UsedRange
If r.Value = v Then
MsgBox (r.Address)
End If
Next
End Sub

The user enters a number and the sub displays all the records (addresses)
that contain that number.
--
Gary''s Student


"Billy B" wrote:

I need some help writing a macro that would prompt the user for a value,
search the active worksheet and display all records that contain the value
input in the inputbox.

Thank you for your help.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Find and display rows with criteria

O.K. then:

1. this version looks for text
2. this version displays entire rows
3. this version will find the text even if it is embedded

Sub billy2()
Dim r As Range, r2 As Range
v = Application.InputBox("Enter value: ", Type:=2)
Rows("1:65536").EntireRow.Hidden = True

For Each r In ActiveSheet.UsedRange
If InStr(r.Value, v) < 0 Then
Rows(r.Row).EntireRow.Hidden = False
End If
Next
Cells(1, 1).Select
End Sub
--
Gary''s Student


"Billy B" wrote:

I was really looking to do something more like a filter. If I entered IT32 in
the inputbox, display the entire row if any cell in that row contains IT32.
Thanks again.

"Gary''s Student" wrote:

Sub billy()
Dim r As Range
v = Application.InputBox("Enter value: ", Type:=1)

For Each r In ActiveSheet.UsedRange
If r.Value = v Then
MsgBox (r.Address)
End If
Next
End Sub

The user enters a number and the sub displays all the records (addresses)
that contain that number.
--
Gary''s Student


"Billy B" wrote:

I need some help writing a macro that would prompt the user for a value,
search the active worksheet and display all records that contain the value
input in the inputbox.

Thank you for your help.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 740
Default Find and display rows with criteria

H Gary,
Can you do an input box for sumproduct....please !

"Gary''s Student" wrote:

O.K. then:

1. this version looks for text
2. this version displays entire rows
3. this version will find the text even if it is embedded

Sub billy2()
Dim r As Range, r2 As Range
v = Application.InputBox("Enter value: ", Type:=2)
Rows("1:65536").EntireRow.Hidden = True

For Each r In ActiveSheet.UsedRange
If InStr(r.Value, v) < 0 Then
Rows(r.Row).EntireRow.Hidden = False
End If
Next
Cells(1, 1).Select
End Sub
--
Gary''s Student


"Billy B" wrote:

I was really looking to do something more like a filter. If I entered IT32 in
the inputbox, display the entire row if any cell in that row contains IT32.
Thanks again.

"Gary''s Student" wrote:

Sub billy()
Dim r As Range
v = Application.InputBox("Enter value: ", Type:=1)

For Each r In ActiveSheet.UsedRange
If r.Value = v Then
MsgBox (r.Address)
End If
Next
End Sub

The user enters a number and the sub displays all the records (addresses)
that contain that number.
--
Gary''s Student


"Billy B" wrote:

I need some help writing a macro that would prompt the user for a value,
search the active worksheet and display all records that contain the value
input in the inputbox.

Thank you for your help.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default Find and display rows with criteria

Yes.

You can use an input box to define ranges with the mouse and then take the
ranges to form an equation.
--
Gary's Student


"driller" wrote:

H Gary,
Can you do an input box for sumproduct....please !

"Gary''s Student" wrote:

O.K. then:

1. this version looks for text
2. this version displays entire rows
3. this version will find the text even if it is embedded

Sub billy2()
Dim r As Range, r2 As Range
v = Application.InputBox("Enter value: ", Type:=2)
Rows("1:65536").EntireRow.Hidden = True

For Each r In ActiveSheet.UsedRange
If InStr(r.Value, v) < 0 Then
Rows(r.Row).EntireRow.Hidden = False
End If
Next
Cells(1, 1).Select
End Sub
--
Gary''s Student


"Billy B" wrote:

I was really looking to do something more like a filter. If I entered IT32 in
the inputbox, display the entire row if any cell in that row contains IT32.
Thanks again.

"Gary''s Student" wrote:

Sub billy()
Dim r As Range
v = Application.InputBox("Enter value: ", Type:=1)

For Each r In ActiveSheet.UsedRange
If r.Value = v Then
MsgBox (r.Address)
End If
Next
End Sub

The user enters a number and the sub displays all the records (addresses)
that contain that number.
--
Gary''s Student


"Billy B" wrote:

I need some help writing a macro that would prompt the user for a value,
search the active worksheet and display all records that contain the value
input in the inputbox.

Thank you for your help.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Find and display rows with criteria


Billy B wrote:
I was really looking to do something more like a filter. If I entered IT32 in
the inputbox, display the entire row if any cell in that row contains IT32.
Thanks again.

"Gary''s Student" wrote:

Sub billy()
Dim r As Range
v = Application.InputBox("Enter value: ", Type:=1)

For Each r In ActiveSheet.UsedRange
If r.Value = v Then
MsgBox (r.Address)
End If
Next
End Sub

The user enters a number and the sub displays all the records (addresses)
that contain that number.
--
Gary''s Student


"Billy B" wrote:

I need some help writing a macro that would prompt the user for a value,
search the active worksheet and display all records that contain the value
input in the inputbox.

Thank you for your help.



my fav to show/hide data based on a criteria is the following sub: you
can modify it to take criteria from a msg box.

you set a range rng sized (rows, cols), in the below sub, criteria is a
formula in column 2.

Sub ShowHide()
Dim rng As Range
With ActiveSheet
Set rng = .Range(.Range("A11"), .Range("A11").End(xlDown))
End With
Set rng = rng.Resize(, 2)
Dim CBX As CheckBox
With ActiveSheet
Set CBX = .CheckBoxes(Application.Caller)
If CBX.Value = xlOn Then
rng.AutoFilter Field:=2, Criteria1:="1"
Else
If .AutoFilterMode Then
If .FilterMode Then
.ShowAllData
End If
.AutoFilterMode = False
End If
End If
End With
End Sub

cheers,
deano

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Find and display rows with criteria

I am using Excel 2000 and I think I need to add a reference to make this work
but which one is it?

Thanks

"deano" wrote:


Billy B wrote:
I was really looking to do something more like a filter. If I entered IT32 in
the inputbox, display the entire row if any cell in that row contains IT32.
Thanks again.

"Gary''s Student" wrote:

Sub billy()
Dim r As Range
v = Application.InputBox("Enter value: ", Type:=1)

For Each r In ActiveSheet.UsedRange
If r.Value = v Then
MsgBox (r.Address)
End If
Next
End Sub

The user enters a number and the sub displays all the records (addresses)
that contain that number.
--
Gary''s Student


"Billy B" wrote:

I need some help writing a macro that would prompt the user for a value,
search the active worksheet and display all records that contain the value
input in the inputbox.

Thank you for your help.



my fav to show/hide data based on a criteria is the following sub: you
can modify it to take criteria from a msg box.

you set a range rng sized (rows, cols), in the below sub, criteria is a
formula in column 2.

Sub ShowHide()
Dim rng As Range
With ActiveSheet
Set rng = .Range(.Range("A11"), .Range("A11").End(xlDown))
End With
Set rng = rng.Resize(, 2)
Dim CBX As CheckBox
With ActiveSheet
Set CBX = .CheckBoxes(Application.Caller)
If CBX.Value = xlOn Then
rng.AutoFilter Field:=2, Criteria1:="1"
Else
If .AutoFilterMode Then
If .FilterMode Then
.ShowAllData
End If
.AutoFilterMode = False
End If
End If
End With
End Sub

cheers,
deano


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 criteria based data and display next to a count in another wk Blurt Excel Discussion (Misc queries) 2 July 22nd 09 11:30 PM
How do I find and copy rows based on specific criteria? Georgew New Users to Excel 3 May 29th 09 11:07 AM
EXCEL - Meet 2 criteria, then find next case of third criteria Elaine Excel Worksheet Functions 3 December 1st 08 10:43 PM
Array to find rows need to insert date criteria Excel 2003 - SPB Excel Discussion (Misc queries) 5 September 1st 07 06:33 PM
Display rows meeting criteria on another sheet & summarize them Showbear Excel Discussion (Misc queries) 2 March 11th 07 08:40 AM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"