abinayadru

New Member
Joined
Jul 3, 2019
Messages
1
Hi Everyone,

I coded this following in adobe PDF using java script and I would now like to convert it into excel. Could you please help me with trying to convert this following code into VBA?
if (event.value == "Distribution") {
var cost = Number(this.getField("cost limit").valueAsString);
if (cost>=200001) {
this.getField("Sps").setItems(["Joe Doe"]);
} else {
this.getField("Sps").setItems(["Chris Worth"]);
}
}

Thank you very much.
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
abinayadru,

I think the following is probably the code you are after. I am assuming that the construction
event.value ==
means that if there is a change on the sheet, and the changed cell contains...


In this case the following should work. It needs to be places in the sheet module for the sheet where the cell will be changed to 'Distribution'. To get there, right click on the sheet tab and select View Code...
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Value = "Distribution" Then
        Range("Sps").Value = IIf(Range("cost limit").Value > 200001, "Joe Doe", "Chris Worth")
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,611
Messages
6,120,510
Members
448,967
Latest member
screechyboy79

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