is something wrong with small piece of code?

rehanemis

Board Regular
Joined
Aug 15, 2016
Messages
50
Hi,
i have added the following code to my worksheet_change event and getting the error while running this code on Excel 2007 but working well on Excel 2013.
Can any body help to solve the issue as i am trying to calculate the things for both column value change. The error message is as: "No Registered JIT debugger was specified"....

VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
 Dim TaxVal, TaxCode As String
 Dim currentCell As Range
 Dim TaxPercent As Double
 TaxCode = "N"


On Error Resume Next

'Processing with J column
    If Target.Column = 10 Then
        If Target.Cells.Offset(0, 2).Value = "" Then
            MsgBox "Tax Code Must be Entered", vbInformation, "Missing Tax Code"
             
            Exit Sub
        ElseIf Target.Cells.Offset(0, 3).Value = "" Or Target.Cells.Offset(0, 3).Value = 0 Then
             
             
            TaxCode = Target.Cells.Offset(0, 2).Value
            TaxPercent = CDbl(Application.VLookup(TaxCode, Sheets("TaxCode").Range("b3:d22"), 3, False))
            Target.Cells.Offset(0, 1).Value = Target.Cells.Value * TaxPercent
            Target.Cells.Offset(0, 3).Value = Target.Cells.Value + Target.Cells.Offset(0, 1).Value
         
            
        
        End If
        
    End If
'Processing with column 13
     If Target.Column = 13 Then
        If Target.Cells.Offset(0, -1).Value = "" Then
            MsgBox "Tax Code Must be Entered", vbInformation, "Missing Tax Code"
         
            Exit Sub
        ElseIf Target.Cells.Offset(0, -3).Value = "" Or Target.Cells.Offset(0, -3).Value = 0 Then
             
            TaxCode = Target.Cells.Offset(0, -1).Value
            
            TaxPercent = CDbl(Application.VLookup(TaxCode, Sheets("TaxCode").Range("b3:d22"), 3, False))
            If TaxPercent = 0 Then
                    Target.Cells.Offset(0, -2).Value = Target.Cells.Value * TaxPercent
                    Target.Cells.Offset(0, -3).Value = Target.Cells.Value - Target.Cells.Offset(0, -2).Value
            
                 Else
                    TaxPercent = TaxPercent + 1
                    Target.Cells.Offset(0, -3).Value = Target.Cells.Value / TaxPercent
                    TaxPercent = TaxPercent - 1
                    Target.Cells.Offset(0, -2).Value = Target.Cells.Offset(0, -3).Value * TaxPercent
                 
             End If
            
        
        End If
        
    End If
 
'End of Mian IF test
End Sub
If someone has best suggestion to deal with please share or modify the code.
thanks
 

Attachments

  • pic.JPG
    pic.JPG
    118.7 KB · Views: 9

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
I think that the error message has something to do with Visual studio, not VBA.
That said It looks as though you might have a permanent loop
 
Upvote 0
Ye s that should work if you put it at the very top of the sub & re-enable events at the end.
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,216,071
Messages
6,128,622
Members
449,460
Latest member
jgharbawi

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