Consulting

Results 1 to 2 of 2

Thread: Histogram help

  1. #1
    VBAX Regular
    Joined
    Jul 2013
    Posts
    10
    Location

    Histogram help

    I am trying to sort the data I get from my rainflow counting algorithm into a histogram.

    1.The first thing I want to do is look for the max value input by the user in cell K2.
    2. Then I want to create a range incrementing by .05 in column D. For example, lets say the user input .3 as their max value. Then in column D I would have:

    D1---- 0-0.05
    D2---- 0.06- 0.1

    so on until it reaches 0.3.

    3. I want to look at the data points from my rainflow counter displayed in column A and count how many cycles for every range in Column D.

    So, I would start at D1 see its 0-0.05 then I would go over to column A (btw I have acounter set at 0) then I would count every number that falls within that range. Then I would display that in E1,reset the counter and move onto the next range.

    Here is the code I do have, it can display the ranges in column D but now I am unsure about how to go through my data points in column A and count the number of cycles withing a specific range from column D.

    [VBA]
    Sub bin_makers()
    Dim mac As Double
    Dim i As Double
    mac = Range("k2") ' user input value for max they wish to use in range
    Dim l As Double

    i = 0 'i is the min value of the range
    p = 1 'p is the row which the range in displaye column D
    l = 0.05 'l is the max value of the range

    Do While i <= mac
    'displays the ranges in cell of column D
    Cells(p, 4).Value = i & " - " & l
    i = l + 0.01
    l = l + 0.05
    p = p + 1
    Loop
    End Sub
    [/VBA]

    Thanks for the help,
    Louis

  2. #2
    VBAX Regular
    Joined
    Jul 2013
    Posts
    10
    Location
    Here is some updated code as for now its two seperate sub routines which I am going to consolidate into one. Let me know if theres any way to simplify it.

    [VBA]
    Sub bin_makers()
    Dim mac As Double
    Dim i As Double
    mac = Range("k2") ' user input value for max they wish to use in range
    Dim l As Double

    i = 0 'i is the min value of the range
    p = 1 'p is the row which the range in displaye column D
    l = 0.05 'l is the max value of the range

    Do While i <= mac
    'displays the ranges in cell of column D
    Cells(p, 4).Value = i
    Cells(p, 5).Value = l
    i = l + 0.01
    l = l + 0.05
    p = p + 1
    Loop
    End Sub
    Sub bin_dis()
    Dim count As Integer
    count = 0

    For tec = 1 To 12
    For bnm = 1 To 6
    If Cells(tec, 1).Value >= Cells(bnm, 4).Value Then
    If Cells(tec, 1).Value <= Cells(bnm, 5).Value Then
    count = count + 1
    Cells(bnm, 6).Value = Cells(bnm, 6).Value + count
    End If
    Else
    Cells(bnm, 6).Value = Cells(bnm, 6).Value + 0
    End If
    count = 0
    Next bnm
    Next tec
    End Sub
    [/VBA]

    Louis

Posting Permissions

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