Reporting back the amount of negative values in a row in a command button.

Romano_odK

Active Member
Joined
Jun 4, 2020
Messages
380
Office Version
  1. 365
Platform
  1. Windows
Good afternoon,

As from all the help I get I collected some VBA code. Now what I would like to achieve is that the amount of row that are negative will be displayed in the command button named "Negatief". Can this be done? Thank you for your time.

The below will not work. What I need is Command button 'Negatief" to be displaying the amount of negative values in the sheet "Boekingen" with table name 'Locatie" with header ""Voorraad". Then the value needs to change when something in sheet changes.

VBA Code:
Private Sub worksheet_change(ByVal target As Range)
Negatief.Caption = "Stock < 0" & Chr(10) & Sheet1.Range("B3").Value

Range("J1").Value = Application.CountIf(Range("Locatie[Voorraad]"), "<0")

End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
If I'm understanding what you're looking for, give this a try...

VBA Code:
Private Sub worksheet_change(ByVal target As Range)
Negatief.Caption = "Stock < 0" & Chr(10) & Application.CountIf(Range("Locatie[Voorraad]"), "<0")

End Sub
 
Upvote 0
Solution
If I'm understanding what you're looking for, give this a try...

VBA Code:
Private Sub worksheet_change(ByVal target As Range)
Negatief.Caption = "Stock < 0" & Chr(10) & Application.CountIf(Range("Locatie[Voorraad]"), "<0")

End Sub
Exactly what I needed, thank you.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,329
Members
452,635
Latest member
laura12345

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