My second part of code is about populating no of months in G cell when no of days Is given in F cell and vice versa. But it throws run time error 13 w

Sathishky

New Member
Joined
Jan 30, 2019
Messages
1
Private Sub Worksheet_Change(ByVal Target As Range)

' If the target column is greater than J And J isn't blank And K is blank then...

If Target.Column > 9 And (Range("C" & Target.Row).Value = "CP" Or Range("C" & Target.Row).Value = "NCD") And (Range("I" & Target.Row).Value = "" Or Range("I" & Target.Row).Value <= "0") Then

' Display error message to this effect

MsgBox "Error! If Mode=CP/NCD Please Enter Coupon rates before moving on"

' Disable events to prevent infinite loop

Application.EnableEvents = False

' Clear the contents of the target cell

Target.ClearContents

' Re-enable events

Application.EnableEvents = True

' Select column K of the target row

Range("I" & Target.Row).Select





End If



Dim FG As Range, t As Range, v As Variant

Dim r As Long

Set t = Target

Set FG = Range("F:G")

If Intersect(t, FG) Is Nothing Then Exit Sub

Application.EnableEvents = False

r = t.Row

v = t.Value

If v = "" Then

Range("F" & r & ":G" & r).Value = ""

End If

If IsNumeric(v) Then

If Intersect(t, Range("G:G")) Is Nothing Then

t.Offset(0, 1).Value = v / 365 * 12

Else

t.Offset(0, -1).Value = v / 12 * 365

End If

End If

Application.EnableEvents = True

End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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