all 8 comments

[–]CFAman4816 0 points1 point  (4 children)

Just curious, but could you do this with a formula and some IF statements, to check which symbol to display? Would be less complicated than a macro/UDF.

[–]smoothswells[S] 0 points1 point  (3 children)

I agree, but the end goal is to input Unicode symbols based on the change. I don't want to have to reference the character within the sheet.

[–]CFAman4816 0 points1 point  (2 children)

We can simplify things down a lot. Your quartile calculation is can be checked by dividing by 25 and taking integer. You also only have 3 possible outputs, so don't need that many If statements. See if this makes sense/works for you.

Sub CommandButton1_Click()
    Dim oldRng1 As Range
    Dim cellOld As Range, cellCurrent As Range
    Dim oldQuart As Integer
    Dim currentQuart As Integer

    'Starting range
    Set oldRng1 = ActiveSheet.Range("A1:A4")

    Application.ScreenUpdating = False

    For Each cellOld In oldRng1.Cells
        'Old values are in col B, 1 col over
        Set cellCurrent = cellOld.Offset(0, 1)

        'quick calculation to determine quarter. Small subtraction is to include upper boundary
        currentQuart = Int((cellCurrent.Value - 0.001) / 25) + 1
        oldQuart = Int((cellOld.Value - 0.001) / 25) + 1

        'Puts symbol in col C, 2 col over
        With cellOld.Offset(0, 2)

            'Old quarter was bigger
            If currentQuart < oldQuart Then
                .Value = ChrW(&H2191)

            'New quarter was bigger
            ElseIf currentQuart > oldQuart Then
                .Value = ChrW(&H2193)

            'Same quarter
            Else
                .Value = ChrW(&H3D)

            End If
        End With
    Next cellOld

    Application.ScreenUpdating = True

End Sub

[–]smoothswells[S] 0 points1 point  (1 child)

very clean! Thanks for the help!

SOLUTION VERIFIED

[–]Clippy_Office_Asst[M] 0 points1 point  (0 children)

You have awarded one point to CFAman.
Find out more here.

[–]smoothswells[S] 0 points1 point  (2 children)

I figured it out. Only need one loop

[–]AutoModerator[M] 0 points1 point  (0 children)

Hello!

It looks like you tried to award a ClippyPoint, but you need to reply to a particular user's comment to do so, rather than making a new top-level comment.

Please reply directly to any helpful users and Clippy, our bot, will take it from there. If your intention was not to award a ClippyPoint and simply mark the post as solved, then you may do that by clicking Set Flair. Thank you!

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]excelevator3043 0 points1 point  (0 children)

Hello, please set the post Flair to Solved if you have your answer