Formula for subtracting from a total, if a specific item is selected from a dropdown

angdilla

New Member
Joined
Apr 11, 2024
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Hello! Is there a way to automatically subtract 1 from a cell when an item is selected from a dropdown? I have a specific number of times I can use each item in the dropdown menu and would like to keep track of how many remaining times are available for each item.

Thank you!
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
You would need a list of the items in the drop down with the corresponding number of times for each item. For example, this can be done by listing the items in column A and their corresponding times in column B all on a different sheet. You could then keep track in column C how many times each item is used. What are the items in the drop down and what are their corresponding numbers? In which cell is the drop down found? We could save a lot of time if you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0
Hello! Is there a way to automatically subtract 1 from a cell when an item is selected from a dropdown? I have a specific number of times I can use each item in the dropdown menu and would like to keep track of how many remaining times are available for each item.

Thank you!

You would need a list of the items in the drop down with the corresponding number of times for each item. For example, this can be done by listing the items in column A and their corresponding times in column B all on a different sheet. You could then keep track in column C how many times each item is used. What are the items in the drop down and what are their corresponding numbers? In which cell is the drop down found? We could save a lot of time if you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
Thank you!



On the Grants tab, columns I-W (row 7 and lower) have a drop-down with 35 different codes. The corresponding numbers tracked are on the Funds Available tab in columns G and O (they are also copied on to rows 2-4 of the Grants tab).

My goal is to enter a grant on the Grants tab, select the different funds I am pulling from in columns I-W, and have 1 removed for the remaining points each time I use a code.
 
Upvote 0
In column A of the Funds Available sheet, you have two occurrences of 'WMALDOC", one for Education and one for Health. When you select "WMALDOC " in the drop downs in the Grants sheet, how do you determine which of the two occurrences of 'WMALDOC" to update in Funds Available sheet?
 
Upvote 0
In column A of the Funds Available sheet, you have two occurrences of 'WMALDOC", one for Education and one for Health. When you select "WMALDOC " in the drop downs in the Grants sheet, how do you determine which of the two occurrences of 'WMALDOC" to update in Funds Available sheet?
That's a great question. If manually doing it, we would just choose the best option. If it is possible to have a formula like I am hoping, we could have both WMALDOC-E and WMALDOC-H as dropdown options to eliminate the duplicate fund code.
 
Upvote 0
Click here to download your file. I have had to remove trailing spaces in some of the Fund names in columns A and I of the Funds Available sheet. I have also added WMALDOC-E and WMALDOC-H to the Fund Codes sheet to update the drop downs and also in column A of the Funds Available sheet. Simply make a selection in the drop downs in the Grants sheet. The macro is in the code module for the Grants sheet. To view the code, right click the tab name for your Grants sheet and click 'View Code'. Close the code window to return to your sheet. This is the code:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    Dim lRowG As Long, lRowFA As Long, fund As Range
    lRowG = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    If Intersect(Target, Range("I7:W" & lRowG)) Is Nothing Then Exit Sub
    lRowFA = Sheets("Funds Available").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Set fund = Sheets("Funds Available").Range("A2:A" & lRowFA, "I2:I" & lRowFA).Find(Target.Value, LookIn:=xlValues, lookat:=xlWhole)
    fund.Offset(, 5).Copy
    If Not fund Is Nothing Then
        fund.Offset(, 6).Value = fund.Offset(, 6).Value - 1
    End If
    Application.ScreenUpdating = False
End Sub
 
Upvote 0
Click here to download your file. I have had to remove trailing spaces in some of the Fund names in columns A and I of the Funds Available sheet. I have also added WMALDOC-E and WMALDOC-H to the Fund Codes sheet to update the drop downs and also in column A of the Funds Available sheet. Simply make a selection in the drop downs in the Grants sheet. The macro is in the code module for the Grants sheet. To view the code, right click the tab name for your Grants sheet and click 'View Code'. Close the code window to return to your sheet. This is the code:
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.CountLarge > 1 Then Exit Sub
    Dim lRowG As Long, lRowFA As Long, fund As Range
    lRowG = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    If Intersect(Target, Range("I7:W" & lRowG)) Is Nothing Then Exit Sub
    lRowFA = Sheets("Funds Available").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Set fund = Sheets("Funds Available").Range("A2:A" & lRowFA, "I2:I" & lRowFA).Find(Target.Value, LookIn:=xlValues, lookat:=xlWhole)
    fund.Offset(, 5).Copy
    If Not fund Is Nothing Then
        fund.Offset(, 6).Value = fund.Offset(, 6).Value - 1
    End If
    Application.ScreenUpdating = False
End Sub

I apologize if it's a user error, but this doesn't seem to be working. When I select a code from the dropdown on the Grants tab, it doesn't update the total number of available points for that code.
 
Upvote 0
You will notice that I selected WENDENC in cells I7 and K8. You will also notice that the value in cell F2 has decreased by 2 from the original value of 120.
angdilla.xlsm
ABCDEFGHIJKLMNO
1
2WACDTAC1WBUREMC2WENDENC118WFORDPC 3WHANBJC3WLUTSTC8WMCGMCC 2WPERBBC
3WAXLDEC2WCASFAC4WFELNAC 4WGABMOC3WKERFAC3WMALDOC EDUCATION3WMORDAC2WPETCAC
4WBLOBEC2WDOUEAC 2WFISGAC2WGEHTRC2WLISBTC 8WMALDOC HEALTH3WOBRSMC3WPETMAC
5 UNRESTRICTED HEALTH EDUCATION FUNDS AVAILABLE
6Award DateGranteeProject Total Grant 57,000.00800.00800.0058,600.00 Funds Used Funds Used Funds Used Funds Used Funds Used Funds Used Funds Used
7 Yes WENDENC
8 Yes WENDENC
Grants


angdilla.xlsm
ABDEFGH
1FundPurposePoints Starting BalanceSpring Points UsedFall Points UsedPoints Remaining
2WACDTACUnrestricted11
3WAXLDECUnrestricted22
4WBLOBECUnrestricted22
5WBUREMCUnrestricted22
6WCASFACUnrestricted44
7WDOUEACUnrestricted22
8WENDENCUnrestricted120118
9WFELNACUnrestricted44
10WFISGACUnrestricted22
11WFORDPCUnrestricted33
Funds Available

The macro is working properly for me unless I misunderstood your request.
 
Upvote 0
You will notice that I selected WENDENC in cells I7 and K8. You will also notice that the value in cell F2 has decreased by 2 from the original value of 120.
angdilla.xlsm
ABCDEFGHIJKLMNO
1
2WACDTAC1WBUREMC2WENDENC118WFORDPC 3WHANBJC3WLUTSTC8WMCGMCC 2WPERBBC
3WAXLDEC2WCASFAC4WFELNAC 4WGABMOC3WKERFAC3WMALDOC EDUCATION3WMORDAC2WPETCAC
4WBLOBEC2WDOUEAC 2WFISGAC2WGEHTRC2WLISBTC 8WMALDOC HEALTH3WOBRSMC3WPETMAC
5 UNRESTRICTED HEALTH EDUCATION FUNDS AVAILABLE
6Award DateGranteeProject Total Grant 57,000.00800.00800.0058,600.00 Funds Used Funds Used Funds Used Funds Used Funds Used Funds Used Funds Used
7 Yes WENDENC
8 Yes WENDENC
Grants


angdilla.xlsm
ABDEFGH
1FundPurposePoints Starting BalanceSpring Points UsedFall Points UsedPoints Remaining
2WACDTACUnrestricted11
3WAXLDECUnrestricted22
4WBLOBECUnrestricted22
5WBUREMCUnrestricted22
6WCASFACUnrestricted44
7WDOUEACUnrestricted22
8WENDENCUnrestricted120118
9WFELNACUnrestricted44
10WFISGACUnrestricted22
11WFORDPCUnrestricted33
Funds Available

The macro is working properly for me unless I misunderstood your request.
My mistake! The macro was being blocked. Thank you so much for your work on this!
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

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