Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default msg box to apply filter

Hi,

I want a macro that has a message box to ask for input and then filters the
data based on hte input. How would I go about this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,836
Default msg box to apply filter

With your data on Sheet1, run this code:
Sub CopyCA()

Dim DestSheet As Worksheet
Set DestSheet = Worksheets("Sheet2")

Dim sRow As Long
Dim dRow As Long
Dim sCount As Long
sCount = 0
dRow = 0

myword = InputBox("Enter items to search for.")

For sRow = 1 To Range("A65536").End(xlUp).Row

If Cells(sRow, "A") Like "*" & myword & "*" Then
sCount = sCount + 1
dRow = dRow + 1
Cells(sRow, "A").Copy Destination:=DestSheet.Cells(dRow, "A")
End If
Next sRow

MsgBox sCount & " Significant rows copied", vbInformation, "Transfer Done"

End Sub


The results are copied/pasted to Sheet2.

HTH,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Kirsty" wrote:

Hi,

I want a macro that has a message box to ask for input and then filters the
data based on hte input. How would I go about this?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 37
Default msg box to apply filter

I am getting an error on the line
If Cells(sRow, "A") Like "*" & myword & "*" Then, any suggestions?

Sub CopyCA()

Dim DestSheet As Worksheet
Set DestSheet = Worksheets("Sheet2")

Dim sRow As Long
Dim dRow As Long
Dim sCount As Long
sCount = 0
dRow = 0

myword = InputBox("Enter required week.")

For sRow = 1 To Range("A65536").End(xlUp).Row

If Cells(sRow, "A") Like "*" & myword & "*" Then
sCount = sCount + 1
dRow = dRow + 1
Cells(sRow, "A").Copy Destination:=DestSheet.Cells(dRow, "A")
End If
Next sRow

MsgBox sCount & " Significant rows copied", vbInformation, "Transfer Done"

End Sub

"Kirsty" wrote:

Hi,

I want a macro that has a message box to ask for input and then filters the
data based on hte input. How would I go about this?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 206
Default msg box to apply filter

Sub Filter()
Dim rng As Range
Dim MyCrit As String

MyCrit = InputBox("Enter Filter Criteria")
Set rng = Range("E1:F8")
rng.AutoFilter Field:=1, Criteria1:=MyCrit
End Sub

Mike F
"Kirsty" wrote in message
...
Hi,

I want a macro that has a message box to ask for input and then filters
the
data based on hte input. How would I go about this?



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
keep total formulas / rows when apply filter mandy Excel Discussion (Misc queries) 1 June 10th 09 07:51 PM
Apply same filter to all sheets in a workbook manfareed Excel Programming 9 July 31st 08 03:34 PM
Apply Auto Filter on One Column Bill Foley Excel Programming 5 March 2nd 07 10:16 AM
Apply more than one filter in macro/vb code Stepnen Excel Programming 1 February 19th 04 07:49 PM
Macro or VB to apply filter in spreadsheet Stevie[_3_] Excel Programming 2 February 18th 04 03:15 PM


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