Macro for worksheet by row

Wondering25

New Member
Joined
Nov 10, 2023
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi
I created a worksheet with a dropdown for each row of the budget worksheet. The dropdown allows the user to determine if they want to use the recommended monthly budget allocation methodology or manually enter the data by month. Since the worksheet requires you to make this determination for each row, I would like to define a macro that will know to zero out the cells in row 2 columns J thru V when "Manually" is selected from the drop-down list. When the user moves to Row 3 and selects "manual", i would like the macro to know to zero out all cells in Row 3 columns J thru V to allow the user to enter in their allocation by month and remove all predefined allocations. Is there a way this can be done? I want to make a master worksheet and replicate it for each department that will need to be budgeted.
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
This macro, to be pasted in the sheet's vbe module, will clear your cells when "Manually" is chosen. I'm supposing that your dropdown is in column A. See if you can adapt it to your project.
VBA Code:
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Cells.CountLarge > 1 And Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub '<- change range as needed
    If Target.Value = "Manually" Then             '<- match text and case with Validation Dropdown
        Application.EnableEvents = False          'avoids event redundant triggering
        Range(Cells(Target.Row, "J"), Cells(Target.Row, "V")).ClearContents
        Application.EnableEvents = True
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,094
Messages
6,123,071
Members
449,092
Latest member
ipruravindra

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