E9 Copedant Pedal Changes

rvan07

New Member
Joined
Sep 25, 2024
Messages
11
Office Version
  1. 2019
Platform
  1. Windows
Hello Mr Excel,
The spreadsheet pic shows cell C3 is active and is generating the changes in cells C17,C22 as per the code. All good.
This is currently the only cell with code in column C and the code works as it should.
The Problem:
I added coding for cell B3 which, when active, generates changes in cells B17,B22, and the coding for cell B4 which, when active, generates changes in cells B15, B18. Everything was working as it should until I added the coding for cell B5 which, when active, was to generate changes in cells B16,B17. B17 did NOT respond.
I suspect there is a conflict because B17 is 'common' in the coding for both B3 and B5.
Is there a 'statement' that would allow this 'common' cell to respond as per the code?
I suspect similar conflicts will occur when coding for cells B6 thru B11 as these cells, when active, will also generate changes in 'common' cells within B13 to B22.
Regarding your response, please note I am new to VBA.
Thank you kindly,
Ron
 

Attachments

  • Pedal_String Pic.png
    Pedal_String Pic.png
    11.7 KB · Views: 15
  • E9 Copedant Code Pic.png
    E9 Copedant Code Pic.png
    78.4 KB · Views: 18
Here's one way (again, I'll leave it to you to populate the other cases) ....

VBA Code:
Sub AdjustPitch(r As Range, n As Long, clr As Long)

    Dim m As Long
   
    With r
        m = Application.Match(.Value, Range("Pitches"), 0) + n - 1
        .Value = Application.Index(Range("Pitches"), 1 + m - 12 * Int(m / 12))
        .Interior.Color = clr
    End With

End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
   
    Dim Pedals As Range, Strings As Range
    Dim r As Long, c As Long, clr(1 To 5) As Long, i As Long
   
    Set Pedals = Range("PedalsAndLevers")
    Set Strings = Range("Strings")
    For i = 1 To 5
        clr(i) = Pedals(i, 1).Interior.Color
    Next i
    Application.ScreenUpdating = False
   
    With Strings
        .FormulaR1C1 = "=INDEX(Pitches,1+MOD(MATCH(RC[-1],Pitches,),12))"
        .Columns(1).FormulaR1C1 = "=RC[-1]"
        .Value = .Value
        .Interior.Pattern = xlNone
    End With
   
    If Not Intersect(Pedals, Target) Is Nothing Then
        If Target.Count = 1 Then 'Do you need to allow for multiple pedals/levers?
            r = Target.Row - Pedals.Row + 1
            c = Target.Column - Pedals.Column + 1
            Select Case r
            Case Is = 1
                Call AdjustPitch(Strings(4, c), 2, clr(r))
                Call AdjustPitch(Strings(9, c), 2, clr(r))
            Case Is = 2
                Call AdjustPitch(Strings(2, c), 1, clr(r))
                Call AdjustPitch(Strings(5, c), 1, clr(r))
            Case Is = 3
           
            Case Is = 4
           
            Case Is = 5
           
            Case Is = 6
           
            Case Is = 7
           
            Case Is = 8
           
            Case Is = 9
                Call AdjustPitch(Strings(2, c), 1, clr(2))
                Call AdjustPitch(Strings(5, c), 1, clr(2))
                Call AdjustPitch(Strings(3, c), -1, clr(5))
                Call AdjustPitch(Strings(7, c), -1, clr(5))
            End Select

        End If
    End If
    Application.ScreenUpdating = True

End Sub
Just one word, FANTASTIC !!! Thank you so very much.
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,225,743
Messages
6,186,778
Members
453,371
Latest member
HMX180

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top