Help with VBA

terry_m

New Member
Joined
Dec 11, 2024
Messages
2
Office Version
  1. 365
Platform
  1. Windows
I have a worksheet that has multiple dropdowns. There is one column (B6:B35) that has several values in the dropdown but if a specific value is selected in one cell I need to force 3 other cells in the same row to be set to a specific value.
Example
If B6 is changed to "Cloud Provider", I need C6 to automatically change to "Subscription", H6 to automatically change to "Consumption" and I6 to automatically change to "SaaS Consumption".
Or if B7 is changed to "Cloud Provider", I need C7, H7, and I7 to automatically change the same way.
Any cell in the range (B6:B35) needs to follow this rule.

As it stands I was able to get it to work if I wrote it like this....
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$B$6" Then
If Target.Value = "Cloud Provider" Then
Range("C6") = "Subscription"
Range("H6") = "Consumption"
Range("I6") = "SaaS Consumption"
MsgBox "B:6 was set to Cloud Provider. That value set the Overall type of the software in C:6, Metric Group in H:6, and the License Metric in I:6."
End If
End If

If Target.Address = "$B$7" Then
If Target.Value = "Cloud Provider" Then
Range("C7") = "Subscription"
Range("H7") = "Consumption"
Range("I7") = "SaaS Consumption"
MsgBox "B:7 was set to Cloud Provider. That value set the Overall type of the software in C:7, Metric Group in H:7, and the License Metric in I:7."
End If
End If

If Target.Address = "$B$8" Then......

End Sub

But that means I need to do that for each row in the spreadsheet. I'm sure there is a simpler why for this to be done but I'm at a lost. Can anyone help?
 

Attachments

  • sample.png
    sample.png
    39.5 KB · Views: 1

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Try something like...

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)

    If Not Intersect(Target, Range("B6:B35")) Is Nothing Then
        Application.EnableEvents = False
        If Target.Value = "Cloud Provider" Then
            Target.Offset(, 1) = "Subscription"
            Target.Offset(, 6) = "Consumption"
            Target.Offset(, 7) = "SaaS Consumption"
            MsgBox "B:" & Target.Row & " was set to Cloud Provider. That value set the Overall type of the software in C:" & Target.Row & ", Metric Group in H:" & Target.Row & ", and the License Metric in I:" & Target.Row & "."
        End If
        Application.EnableEvents = True
    End If

End Sub

Welcome to the forum but can you please use code tags in future
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,618
Messages
6,179,916
Members
452,949
Latest member
beartooth91

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