#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 39
Default Precedents

Hi All,

I am using sumif worksheet function in sheet I would like to give an example
here...
Apples 100
Apples 100
Mangos 150
Apples 10
I am using this formula in cell B5:
=Sumif(A1:A4,A5,B1:B4) I just want that when I press
Ctrl + [ in my sumif holding formula it select only those cell that meets my
given criteria specification, rather select the range A1:B5. is there any
way to this




  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 434
Default Precedents

hi, Abdul !

I am using sumif worksheet function in sheet I would like to give an example here...
Apples 100
Apples 100
Mangos 150
Apples 10
I am using this formula in cell B5: =Sumif(A1:A4,A5,B1:B4)
I just want that when I press Ctrl + [ in my sumif holding formula
it select only those cell that meets my given criteria specification
rather select the range A1:B5. is there any way to this


(i.e.) the following sub does what you ask (selects only the matching cells in B1:B4)
you will need to assign "the sub" to any short-cut key (i.e. in your workbook_open event)
and release "the short-cut key" (i.e. in your workbook_beforeclose event) -???-

Sub myMatchingSumif()
Dim theFunction As String, theCriteria As String, theCondition As String, _
theResults As String, theRange As Range, n As Integer, Temp As String, Tmp
If ActiveCell.HasFormula Then theFunction = ActiveCell.Formula Else Exit Sub
If Mid(theFunction, 2, 5) < "SUMIF" Then Exit Sub
Temp = Mid(theFunction, 8, Len(theFunction) - 8)
Tmp = Split(Temp, ",")
theCriteria = Tmp(LBound(Tmp))
theCondition = Tmp(LBound(Tmp) + 1)
theResults = Tmp(LBound(Tmp) + 2)
With Range(theCriteria)
For n = 1 To .Count
If .Cells(n) = Range(theCondition) Then
Set theRange = Union(IIf(theRange Is Nothing, _
Range(theResults).Cells(n), theRange), Range(theResults).Cells(n))
End If
Next
End With
If Not theRange Is Nothing Then theRange.Select: Set theRange = Nothing
End Sub

hth,
hector.

*IF* you need this sub for xl-97 (VBA5 doesn't support split-vba function)...
change this:
Tmp = Split(Temp, ",")
to this:
Tmp = Evaluate("{""" & Application.Substitute(Temp, ",", """,""") & """}")


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 39
Default Precedents

Thank you very much for your code, its exactly works as I want.

"Héctor Miguel" wrote:

hi, Abdul !

I am using sumif worksheet function in sheet I would like to give an example here...
Apples 100
Apples 100
Mangos 150
Apples 10
I am using this formula in cell B5: =Sumif(A1:A4,A5,B1:B4)
I just want that when I press Ctrl + [ in my sumif holding formula
it select only those cell that meets my given criteria specification
rather select the range A1:B5. is there any way to this


(i.e.) the following sub does what you ask (selects only the matching cells in B1:B4)
you will need to assign "the sub" to any short-cut key (i.e. in your workbook_open event)
and release "the short-cut key" (i.e. in your workbook_beforeclose event) -???-

Sub myMatchingSumif()
Dim theFunction As String, theCriteria As String, theCondition As String, _
theResults As String, theRange As Range, n As Integer, Temp As String, Tmp
If ActiveCell.HasFormula Then theFunction = ActiveCell.Formula Else Exit Sub
If Mid(theFunction, 2, 5) < "SUMIF" Then Exit Sub
Temp = Mid(theFunction, 8, Len(theFunction) - 8)
Tmp = Split(Temp, ",")
theCriteria = Tmp(LBound(Tmp))
theCondition = Tmp(LBound(Tmp) + 1)
theResults = Tmp(LBound(Tmp) + 2)
With Range(theCriteria)
For n = 1 To .Count
If .Cells(n) = Range(theCondition) Then
Set theRange = Union(IIf(theRange Is Nothing, _
Range(theResults).Cells(n), theRange), Range(theResults).Cells(n))
End If
Next
End With
If Not theRange Is Nothing Then theRange.Select: Set theRange = Nothing
End Sub

hth,
hector.

*IF* you need this sub for xl-97 (VBA5 doesn't support split-vba function)...
change this:
Tmp = Split(Temp, ",")
to this:
Tmp = Evaluate("{""" & Application.Substitute(Temp, ",", """,""") & """}")



  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 434
Default Precedents

hi, Abdul !

Thank you very much for your code, its exactly works as I want.


thank you for your feed-back ;)

regards,
hector.

I am using sumif worksheet function in sheet I would like to give an example here...
Apples 100
Apples 100
Mangos 150
Apples 10
I am using this formula in cell B5: =Sumif(A1:A4,A5,B1:B4)
I just want that when I press Ctrl + [ in my sumif holding formula
it select only those cell that meets my given criteria specification
rather select the range A1:B5. is there any way to this


(i.e.) the following sub does what you ask (selects only the matching cells in B1:B4)
you will need to assign "the sub" to any short-cut key (i.e. in your workbook_open event)
and release "the short-cut key" (i.e. in your workbook_beforeclose event) -???-

Sub myMatchingSumif()
Dim theFunction As String, theCriteria As String, theCondition As String, _
theResults As String, theRange As Range, n As Integer, Temp As String, Tmp
If ActiveCell.HasFormula Then theFunction = ActiveCell.Formula Else Exit Sub
If Mid(theFunction, 2, 5) < "SUMIF" Then Exit Sub
Temp = Mid(theFunction, 8, Len(theFunction) - 8)
Tmp = Split(Temp, ",")
theCriteria = Tmp(LBound(Tmp))
theCondition = Tmp(LBound(Tmp) + 1)
theResults = Tmp(LBound(Tmp) + 2)
With Range(theCriteria)
For n = 1 To .Count
If .Cells(n) = Range(theCondition) Then
Set theRange = Union(IIf(theRange Is Nothing, _
Range(theResults).Cells(n), theRange), Range(theResults).Cells(n))
End If
Next
End With
If Not theRange Is Nothing Then theRange.Select: Set theRange = Nothing
End Sub

hth,
hector.

*IF* you need this sub for xl-97 (VBA5 doesn't support split-vba function)...
change this:
Tmp = Split(Temp, ",")
to this:
Tmp = Evaluate("{""" & Application.Substitute(Temp, ",", """,""") & """}")



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
Exact Precedents Abdul Shakeel Excel Worksheet Functions 8 July 23rd 08 04:55 AM
Tracing precedents johnston Excel Worksheet Functions 0 May 18th 07 12:21 PM
Formula Precedents Brendan Vassallo Excel Discussion (Misc queries) 2 September 11th 06 12:09 AM
Excel Precedents Joshua Bright Excel Discussion (Misc queries) 1 July 28th 05 06:22 PM
Precedents do not work Paula Excel Worksheet Functions 1 March 30th 05 08:40 PM


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

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"