Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Filtering Results in Excel & VBA

Hi

I'm writing a reporting system that takes an array of data with 25 columns,
and has a front end that allows the user to produce reports based on the
required criteria. All is working fine, unless the value to search for
strToFind is in multiple columns (for example, columns 19 (Success), 20
(Impact) & 21 (Effort) all have High,Medium & Low as options). For these
searches, the report returns any rows which feature any of these values.

How can I limit the search to only a specific column but return the entire
array?

Code is copied below - I have used a series of subroutines to get the
strToFind, then pass it to a generic engine which runs the search and calls
the formatting engine. This may be where the problem is, since searching a
specific column may require passing the index of that column to the reporting
engine.

The variable strToFind is passed globally, it is working fine
----------------------------------------------------------------------------------------
Sub Success_Report()
' Success_Report Macro recorded 20/02/2007 by (Me)

strToFind = Worksheets("Main").Range("D37")
Application.Run "'Report Generator v1.xls'!Run_Report"

End Su
----------------------------------------------------------------------------------------
Sub Impact_Report()
' Impact_Report Macro recorded 20/02/2007 by (Me)

strToFind = Worksheets("Main").Range("D39")
Application.Run "'Report Generator v1.xls'!Run_Report"

End Su
----------------------------------------------------------------------------------------
Sub Effort_Report()
' Effort_Report Macro recorded 20/02/2007 by (Me)

strToFind = Worksheets("Main").Range("D41")
Application.Run "'Report Generator v1.xls'!Run_Report"

End Su
----------------------------------------------------------------------------------------
Sub Run_Report()
' Run_Report Macro recorded 20/02/2007 by (Me)
' This macro is the reporting engine
' It is called by each macro after the report criteria is set

Dim intS As Integer
Dim rngY As Range
Dim wSht As Worksheet
intS = 1

'Clear any existing report information
Application.Run "'Report Generator v1.xls'!Clear_Report"

Application.ScreenUpdating = True
Worksheets("Imported Data").Visible = True
Worksheets("Imported Data").Activate
Application.Run "'Report Generator v1.xls'!Select_Data"

Set wSht = Worksheets("Report")
With Selection
Set rngY = .Find(what:=strToFind, LookAt:=xlPart)
If Not rngY Is Nothing Then
FirstAddress = rngY.Address
Do
rngY.EntireRow.Copy wSht.Cells(intS, 1)
intS = intS + 1
Set rngY = .FindNext(rngY)
Loop While Not rngY Is Nothing And rngY.Address <
FirstAddress
End If
End With

' Run the report formatting engine
Worksheets("Imported Data").Visible = False
Application.Run "'Report Generator v1.xls'!Report_Format"

End Sub







  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Filtering Results in Excel & VBA

you limit your search to

With Selection

Find searches the selection. Make sure the column you want to search is
selected.

--
Regards,
Tom Ogilvy


"D Zandveld" wrote in message
...
Hi

I'm writing a reporting system that takes an array of data with 25
columns,
and has a front end that allows the user to produce reports based on the
required criteria. All is working fine, unless the value to search for
strToFind is in multiple columns (for example, columns 19 (Success), 20
(Impact) & 21 (Effort) all have High,Medium & Low as options). For these
searches, the report returns any rows which feature any of these values.

How can I limit the search to only a specific column but return the entire
array?

Code is copied below - I have used a series of subroutines to get the
strToFind, then pass it to a generic engine which runs the search and
calls
the formatting engine. This may be where the problem is, since searching a
specific column may require passing the index of that column to the
reporting
engine.

The variable strToFind is passed globally, it is working fine.
----------------------------------------------------------------------------------------
Sub Success_Report()
' Success_Report Macro recorded 20/02/2007 by (Me)

strToFind = Worksheets("Main").Range("D37")
Application.Run "'Report Generator v1.xls'!Run_Report"

End Sub
----------------------------------------------------------------------------------------
Sub Impact_Report()
' Impact_Report Macro recorded 20/02/2007 by (Me)

strToFind = Worksheets("Main").Range("D39")
Application.Run "'Report Generator v1.xls'!Run_Report"

End Sub
----------------------------------------------------------------------------------------
Sub Effort_Report()
' Effort_Report Macro recorded 20/02/2007 by (Me)

strToFind = Worksheets("Main").Range("D41")
Application.Run "'Report Generator v1.xls'!Run_Report"

End Sub
----------------------------------------------------------------------------------------
Sub Run_Report()
' Run_Report Macro recorded 20/02/2007 by (Me)
' This macro is the reporting engine
' It is called by each macro after the report criteria is set

Dim intS As Integer
Dim rngY As Range
Dim wSht As Worksheet
intS = 1

'Clear any existing report information
Application.Run "'Report Generator v1.xls'!Clear_Report"

Application.ScreenUpdating = True
Worksheets("Imported Data").Visible = True
Worksheets("Imported Data").Activate
Application.Run "'Report Generator v1.xls'!Select_Data"

Set wSht = Worksheets("Report")
With Selection
Set rngY = .Find(what:=strToFind, LookAt:=xlPart)
If Not rngY Is Nothing Then
FirstAddress = rngY.Address
Do
rngY.EntireRow.Copy wSht.Cells(intS, 1)
intS = intS + 1
Set rngY = .FindNext(rngY)
Loop While Not rngY Is Nothing And rngY.Address <
FirstAddress
End If
End With

' Run the report formatting engine
Worksheets("Imported Data").Visible = False
Application.Run "'Report Generator v1.xls'!Report_Format"

End Sub









  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 33
Default Filtering Results in Excel & VBA

Thanks Tom, worked a treat.

"Tom Ogilvy" wrote:

you limit your search to

With Selection

Find searches the selection. Make sure the column you want to search is
selected.

--
Regards,
Tom Ogilvy


"D Zandveld" wrote in message
...
Hi

I'm writing a reporting system that takes an array of data with 25
columns,
and has a front end that allows the user to produce reports based on the
required criteria. All is working fine, unless the value to search for
strToFind is in multiple columns (for example, columns 19 (Success), 20
(Impact) & 21 (Effort) all have High,Medium & Low as options). For these
searches, the report returns any rows which feature any of these values.

How can I limit the search to only a specific column but return the entire
array?

Code is copied below - I have used a series of subroutines to get the
strToFind, then pass it to a generic engine which runs the search and
calls
the formatting engine. This may be where the problem is, since searching a
specific column may require passing the index of that column to the
reporting
engine.

The variable strToFind is passed globally, it is working fine.
----------------------------------------------------------------------------------------
Sub Success_Report()
' Success_Report Macro recorded 20/02/2007 by (Me)

strToFind = Worksheets("Main").Range("D37")
Application.Run "'Report Generator v1.xls'!Run_Report"

End Sub
----------------------------------------------------------------------------------------
Sub Impact_Report()
' Impact_Report Macro recorded 20/02/2007 by (Me)

strToFind = Worksheets("Main").Range("D39")
Application.Run "'Report Generator v1.xls'!Run_Report"

End Sub
----------------------------------------------------------------------------------------
Sub Effort_Report()
' Effort_Report Macro recorded 20/02/2007 by (Me)

strToFind = Worksheets("Main").Range("D41")
Application.Run "'Report Generator v1.xls'!Run_Report"

End Sub
----------------------------------------------------------------------------------------
Sub Run_Report()
' Run_Report Macro recorded 20/02/2007 by (Me)
' This macro is the reporting engine
' It is called by each macro after the report criteria is set

Dim intS As Integer
Dim rngY As Range
Dim wSht As Worksheet
intS = 1

'Clear any existing report information
Application.Run "'Report Generator v1.xls'!Clear_Report"

Application.ScreenUpdating = True
Worksheets("Imported Data").Visible = True
Worksheets("Imported Data").Activate
Application.Run "'Report Generator v1.xls'!Select_Data"

Set wSht = Worksheets("Report")
With Selection
Set rngY = .Find(what:=strToFind, LookAt:=xlPart)
If Not rngY Is Nothing Then
FirstAddress = rngY.Address
Do
rngY.EntireRow.Copy wSht.Cells(intS, 1)
intS = intS + 1
Set rngY = .FindNext(rngY)
Loop While Not rngY Is Nothing And rngY.Address <
FirstAddress
End If
End With

' Run the report formatting engine
Worksheets("Imported Data").Visible = False
Application.Run "'Report Generator v1.xls'!Report_Format"

End Sub










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
Getting no results from Advanced Filtering in Excel 2007 Environmental Cowboy Excel Discussion (Misc queries) 1 March 21st 08 05:29 PM
Filtering results Tom D[_3_] Excel Discussion (Misc queries) 3 September 26th 07 03:57 AM
display count/results of filtering Excel in status bar JayDax Excel Discussion (Misc queries) 2 July 21st 05 11:41 PM
Filtering results GazMo[_4_] Excel Programming 2 October 15th 04 08:12 PM
Filtering results GazMo[_3_] Excel Programming 1 October 14th 04 10:24 PM


All times are GMT +1. The time now is 05:06 AM.

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"