Stop Macro if Data is .........

christian21077

New Member
Joined
Mar 30, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello everyone. I need to be able to stop a macro if the data of certain cells go to a negative number. The cells in question have a formula. (I dont know if that matters or no). Let me give you some background. The macro I have is basically using "goal seek" to find out angles. The macro is for several cells. Two Things I need to do. 1- I need to tell the macro to stop looking if cells BI31 through BK31 are negative numbers. 2- I need to know where to place the line, at the end of whole macro, or in between each process. Take a look at the macro I have:

Sub FindAngle()
'
' FindAngle Macro
'
' Keyboard Shortcut: Ctrl+Shift+M
'
Application.CutCopyMode = False
Application.CutCopyMode = False
Application.CutCopyMode = False
Range("BP31").GoalSeek Goal:=0, ChangingCell:=Range("BL31")
Range("BP32").Select
Application.CutCopyMode = False
Application.CutCopyMode = False
Application.CutCopyMode = False
Range("BP32").GoalSeek Goal:=0, ChangingCell:=Range("BL32")
Range("BP33").Select

This macro goes up to BL44. So pretty much the same thing throughout the macro just different ranges. Your help will be appreciated.
 

Attachments

  • Macro Sheet.jpg
    Macro Sheet.jpg
    128.2 KB · Views: 11

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,215,043
Messages
6,122,812
Members
449,095
Latest member
m_smith_solihull

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