#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default row numbers

I use a filter to sort data, then use a macro for data calculation. Ho
can I tell the macro to always choose the first 10 rows for th
calculation, regardless of row numbers

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default row numbers

Hi "dflorine " ,
Depending on your formula you can use ranges that put
addresses into double quotes, or you can use INDIRECT.
If you posted your formula you would get more specific help.,
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"dflorine " wrote in message ...
I use a filter to sort data, then use a macro for data calculation. How
can I tell the macro to always choose the first 10 rows for the
calculation, regardless of row numbers?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default row numbers

You could mark the rows, and use the marked rows in a SUMIF or
SUMPRODUCT formula, e.g. =SUMIF(I:I,"X",E:E)

or find the row of the tenth item, and build a SUBTOTAL formula in a macro.

'=======================================
Sub MarkVisRows()
Dim rng As Range
Dim c As Range
Dim i As Integer
Set rng = ActiveSheet.AutoFilter.Range
i = 1
Columns("I").ClearContents
For Each c In rng.Columns(1).SpecialCells(xlVisible)
If c.Row 1 Then
If i 10 Then
Exit Sub
Else
c.Offset(0, 8).Value = "X"
i = i + 1
End If
End If
Next
Range("L1").Formula = "=SUMIF(E1:E" & r & ")"
End Sub
'=========================
Sub SubtotalTenRows()
Dim rng As Range
Dim c As Range
Dim i As Integer
Dim r As Long
Set rng = ActiveSheet.AutoFilter.Range
i = 1
Columns("I").ClearContents
For Each c In rng.Columns(1).SpecialCells(xlVisible)
If c.Row 1 Then
If i 10 Then
Else
r = c.Row
i = i + 1
End If
End If
Next
Range("K1").Formula = "=SUBTOTAL(9,E1:E" & r & ")"
End Sub
'=================================

dflorine < wrote:
I use a filter to sort data, then use a macro for data calculation. How
can I tell the macro to always choose the first 10 rows for the
calculation, regardless of row numbers?


--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 422
Default row numbers

I took this approach:
My data table has a single-row of headerinfo on Row3 - first data on row 4
downward
I like having a column(1) Inserted in most of my datatables when I use
Auto-Filtering
with a formula in A4 of =SUBTOTAL(3,$B$4:B4) and copied down to the end
of the
data. Label in A3 of "Seq #".

So that when I filter my Column A always gives me a sequential row count of
the visible
cells. Nice feature, huh..

In my Column C cell C1 I entered:

=SUBTOTAL(9,INDIRECT("C3:C"&MATCH(5,$A3:$A20,0)+2) ) and copied across
replacing in each copied cell the two "C"s to the appropriate column letter.
Once
Done it works like a charm.

Hope this helps!!!
It helped me,,,







"dflorine " wrote in message
...
I use a filter to sort data, then use a macro for data calculation. How
can I tell the macro to always choose the first 10 rows for the
calculation, regardless of row numbers?


---
Message posted from http://www.ExcelForum.com/



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
Excel, change column of negative numbers to positive numbers? Nita New Users to Excel 3 November 27th 07 04:54 AM
Excel 2002 : Convert Positive Numbers to Negative Numbers ? Mr. Low Excel Discussion (Misc queries) 2 November 6th 06 03:30 PM
change 2000 cells (negative numbers) into positive numbers lisbern Excel Worksheet Functions 2 August 16th 06 05:54 PM
Help! How do you get excel to find the x(changes daily, marked in a cell from another formula) highest numbers in a group of numbers and sum them up? C-Man23 Excel Worksheet Functions 3 January 19th 06 09:52 AM
Help! How do you get excel to find the x(changes daily, marked in a cell from another formula) highest numbers in a group of numbers and sum them up? C-Man23 Excel Worksheet Functions 1 January 9th 06 01:23 PM


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