+ Reply to Thread
Results 1 to 2 of 2

creating counts from a range of cells

  1. #1
    Registered User
    Join Date
    12-01-2006
    Posts
    15

    creating counts from a range of cells

    Hey, hope someone can give me some useful advice...basically what i am trying to do is look at each cell in a column (or range), then increase the appropriate counter depending on which range the value falls within.here is my code thus far...

    any help appreciated!!

    tan :-)

    Sub test()

    Dim count1 As Integer
    Dim count2 As Integer
    Dim count3 As Integer
    Dim i As Integer
    Dim x As Integer

    x = 0
    count1 = 0
    count2 = 0
    count3 = 0

    For Counter = 1 To 6 ' this is how many samples in 8 hrs
    'Set curCell = Worksheets("rad_10secs_5days").Cells(x, 9).Value
    'Worksheets("rad_10secs_5days")
    If Cells(x, 9).Value < 86 Then 'if less than 86%
    count1 = count1 + 1

    ElseIf Cells(x, 9).Value >= 86 And Cells(x, 9).Value < 95 Then
    count2 = count2 + 1 'if between 86-94% inclusive

    Else ' if greater than 94%
    count3 = count3 + 1

    End If

    x = x + 1

    Next Counter

    MsgBox "Saturation < 86% is " & count1 & vbCrLf & "Saturation 86-94 is " & count2 & vbCrLf & "Saturation > 94% is " & count3

    'Worksheets("Sheet2").Range ("A1:B5")-how to define range in worksheet

    End Sub

  2. #2
    Registered User
    Join Date
    12-01-2006
    Posts
    15
    ah, found where i was going wrong...i got rid of x and put counter there-effectively doing the same thing anyway.and wallah.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1