If statement problem - #div/0!

jgold20

Board Regular
Joined
Feb 4, 2018
Messages
135
Cubic feet Filing or Scheduling & CC FeesMinimum MoveCompany CodeEnter Minimum Move Amount Minimum [FONT=&quot]Price [/FONT]per[FONT=&quot]CF [/FONT]
YESYESL500#DIV/0!
N #DIV/0!
NO #DIV/0!
#DIV/0!

<colgroup><col width="91" style="width: 68pt;"><col width="99" style="width: 74pt;"><col width="89" style="width: 67pt;"><col width="99" style="width: 74pt;"><col width="123" style="width: 92pt;"><col width="97" style="width: 73pt;"></colgroup><tbody>
</tbody>
In the above example, when cubic feet is 0, it returns a #div/0! error. The statement I am using is =IF(G3="YES",(I3/E3),0) for minimum move. If I use the drop down and change minimum move to NO, it returns a 0. I have tried everything I could think of and still receive the #div/0!. Is there any way to avoid the error. I understand why it is happening
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
Same result as before with the new code:

Change to NO
a) Check1 macro invoked - OK
Changed to YES
a) Check1 macro invoked - OK

SAME MESSAGE FOR BOTH
 
Upvote 0
I figured out what the problem is, my drop-down box was uppercase. Once I changed the YES in the VBA code to YES it worked. Now I want to clear the contents of the cell and if it is NO. This is not working. Below is the code:

Private Sub Worksheet_Change(ByVal Target As Range)


Dim cell As Range



' Check to see if cell G3 updated
If Target.Address = Range("G3").Address Then
If Target.Value = "YES" Then
Application.EnableEvents = False
Range("E9:E12").Value = Range("J3:J6").Value
Application.EnableEvents = True
If Target.Value = "NO" Then
Application.EnableEvents = False
Range("E9:E12").ClearContents
Application.EnableEvents = True
End If
End If
End If

End Sub
 
Upvote 0
Joe, I appreciate all of your time and effort. I used the below and it is working. In addition, I found a second way to do it with a module calling a worksheet. Ty

Private Sub Worksheet_Change(ByVal Target As Range)


Dim cell As Range



' Check to see if cell G3 updated
If Target.Address = Range("G3").Address Then
If Target.Value = "YES" Then
Application.EnableEvents = False
Range("E9:E12").Value = Range("J3:J6").Value
Application.EnableEvents = True
Else
If Target.Address = Range("G3").Address Then
If Target.Value = "NO" Then
Application.EnableEvents = False
Range("E9:E12").ClearContents
Application.EnableEvents = True
End If
End If
End If
End If

End Sub


Sub min_move_yes(ByVal Target As Range)
If Not Intersect(Target, Range("G3")) Is Nothing Then
Select Case Range("G3")
Case "YES": Module1
End Select
End If
End Sub
End Sub

Private Sub Worksheet_Change(ByVal Target As Range)


Dim cell As Range

Range("E9:E12").Value = Range("J3:J6").Value

End Sub
 
Last edited:
Upvote 0
You are welcome.

Glad you got it all sorted out now.
 
Upvote 0
If you have a chance, I posted another question:

[h=2]VBA code - have 1 woking, need to add another one[/h]
 
Upvote 0

Forum statistics

Threads
1,216,101
Messages
6,128,845
Members
449,471
Latest member
lachbee

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