Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Row Count...

I want to count the rows bottom up for a column value. As soon as the
sign is changed or the number is the value of a zero, counter finishes
counting. Ex,
-2.1
0.3
-1.1
44
13.1
12.2
counter x = 3

31.2
44.8
9.4
10.4
-2.2
-11.1
counter x = 2

5.3
9
0
3.2
counter x = 1

Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Row Count...

fzl2007 wrote:

I want to count the rows bottom up for a column value. As soon as the
sign is changed or the number is the value of a zero, counter finishes
counting. Ex,


Something like this, perhaps?

Function FindSignChangeOrZero() As Long
'Replace ActiveCell with whatever you need...
col = ActiveCell.Column
If ActiveCell.SpecialCells(xlCellTypeLastCell).Value < 0 Then
s = Sgn(Cells.SpecialCells(xlCellTypeLastCell).Value)
c = 1
For L0 = Cells.SpecialCells(xlCellTypeLastCell).Row - 1 To 1 Step -1
tmp = Cells(L0, col).Value
If (Sgn(tmp) < s) Or (0 = tmp) Then Exit For
c = c + 1
Next
FindSignChangeOrZero = c
End If
End Function

If the bottom value is 0, this will return 0.

--
I will be the power surge -- Shock to the system
Electrified, amplified -- Shock to the system
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 23
Default Row Count...

On Feb 21, 11:22*am, "Auric__" wrote:
fzl2007 wrote:
I want to count the rows bottom up for a column value. As soon as the
sign is changed or the number is the value of a zero, counter finishes
counting. Ex,


Something like this, perhaps?

* FunctionFindSignChangeOrZero() As Long
* * 'Replace ActiveCell with whatever you need...
* * col = ActiveCell.Column
* * If ActiveCell.SpecialCells(xlCellTypeLastCell).Value < 0 Then
* * * s = Sgn(Cells.SpecialCells(xlCellTypeLastCell).Value)
* * * c = 1
* * * For L0 = Cells.SpecialCells(xlCellTypeLastCell).Row - 1 To 1 Step -1
* * * * tmp = Cells(L0, col).Value
* * * * If (Sgn(tmp) < s) Or (0 = tmp) Then Exit For
* * * * c = c + 1
* * * Next
* * *FindSignChangeOrZero= c
* * End If
* End Function

If the bottom value is 0, this will return 0.

--
I will be the power surge -- Shock to the system
Electrified, amplified -- Shock to the system


How do I apply this above code so that it will look up every other
column starting Column B on "Sheet1" and place the result on F6
"Sheet2", Column D on "Sheet1" and place result on F7 "Sheet2"; Column
F on "Sheet1" and place result on F8 on "Sheet2" and on ... until
column is empty?

Basically, The data is on "Sheet1" and results will show on "Sheet2".

Thanks again,
Faye


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Row Count...

fzl2007 wrote:

On Feb 21, 11:22*am, "Auric__" wrote:
fzl2007 wrote:
I want to count the rows bottom up for a column value. As soon as the
sign is changed or the number is the value of a zero, counter finishes
counting. Ex,


Something like this, perhaps?

[snip]
If the bottom value is 0, this will return 0.


How do I apply this above code so that it will look up every other
column starting Column B on "Sheet1" and place the result on F6
"Sheet2", Column D on "Sheet1" and place result on F7 "Sheet2"; Column
F on "Sheet1" and place result on F8 on "Sheet2" and on ... until
column is empty?

Basically, The data is on "Sheet1" and results will show on "Sheet2".


Replace my previous function with this:

Sub FindSignChangeOrZero()
For c = 2 To Sheet1.Cells.SpecialCells(xlCellTypeLastCell).Colu mn Step 2
s = Sgn(Sheet1.Cells(1, c).End(xlDown).Value)
counter = 1
For L0 = Sheet1.Cells(1, c).End(xlDown).Row - 1 To 1 Step -1
tmp = Sheet1.Cells(L0, c).Value
If (Sgn(tmp) < s) Or (0 = tmp) Then Exit For
counter = counter + 1
Next
Sheet2.Cells((c / 2) + 5, 6).Value = counter
Next
End Sub

--
The best path is the hardest earned.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 538
Default Row Count...

Auric__ wrote:

fzl2007 wrote:

On Feb 21, 11:22*am, "Auric__" wrote:
fzl2007 wrote:
I want to count the rows bottom up for a column value. As soon as the
sign is changed or the number is the value of a zero, counter finishes
counting. Ex,

Something like this, perhaps?

[snip]
If the bottom value is 0, this will return 0.


How do I apply this above code so that it will look up every other
column starting Column B on "Sheet1" and place the result on F6
"Sheet2", Column D on "Sheet1" and place result on F7 "Sheet2"; Column
F on "Sheet1" and place result on F8 on "Sheet2" and on ... until
column is empty?

Basically, The data is on "Sheet1" and results will show on "Sheet2".


Replace my previous function with this:


If you want to have the sub do as the function did regarding the bottom cell
= 0, use this instead:

Sub FindSignChangeOrZero()
For c = 2 To Sheet1.Cells.SpecialCells(xlCellTypeLastCell).Colu mn Step 2
s = Sgn(Sheet1.Cells(1, c).End(xlDown).Value)
If s < 0 Then
counter = 1
For L0 = Sheet1.Cells(1, c).End(xlDown).Row - 1 To 1 Step -1
tmp = Sheet1.Cells(L0, c).Value
If (Sgn(tmp) < s) Or (0 = tmp) Then Exit For
counter = counter + 1
Next
Sheet2.Cells((c / 2) + 5, 6).Value = counter
Else
Sheet2.Cells((c / 2) + 5, 6).Value = 0
End If
Next
End Sub

--
Okay, team, dogpile on the girl with the jetpack.


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
count duplicats, display incremental count, restart count at changein value JenIT Excel Programming 2 August 24th 10 09:10 PM
Count Employee Work Time - Don't Double-count Overlapping Apts. J Excel Worksheet Functions 0 April 27th 07 05:52 AM
Excel 2000, count, sort a list & count totals? sunslight Excel Worksheet Functions 1 April 9th 07 05:46 PM
Excel Count characters in a textbox to display character count? [email protected] Excel Programming 1 February 8th 07 06:31 AM
Count Intervals of Filtered TEXT values in Column and Return Count across a Row Sam via OfficeKB.com Excel Worksheet Functions 9 July 31st 05 03:37 AM


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