Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Convert Excel formula to Javascript

New Here ,
Apr 29, 2016 Apr 29, 2016

Hello,

Looking to convert these 2 formulas to work in Javascript.

=IF(D11=0,,IF(D11<=50,16.25,IF(AND(D11>=51,D11<=100),31.5,IF(AND(D11>=101,D11<=150),42.75,IF(AND(D11>=151,D11<=200),52.25,IF(AND(D11>=201,D11<=250),60.5,IF(AND(D11>=251,D11<=300),68.25,0)))))))

=IF(AND(D11>=301,D11<=350),75.25,IF(AND(D11>=351,D11<=400),82,IF(AND(D11>=401,D11<=450),82,IF(AND(D11>=451,D11<=500),94.75,IF(AND(D11>=501,D11<=1600),(D11*0.2),IF(D11>=1600,320,0))))))

TOPICS
Acrobat SDK and JavaScript
1.3K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 29, 2016 Apr 29, 2016

You may want to read up on the JavaScript core syntax. If you’ve managed to learn Excel macro programming, this should not be too complicated. Specifically, what you are looking for here is the if/else statement.

I've translated the first few cases of your first formula for you, you can now follow that pattern and add the remaining cases:

var v = this.getField("D11").value;

event.value = 0;

if (v == 0) {

  event.value = 0;

}

else if (v >=0 && v <= 50) {

  event.value = 16.25;

}

else if (v > 50 && v <= 100

...
Translate
Community Expert ,
Apr 29, 2016 Apr 29, 2016

You may want to read up on the JavaScript core syntax. If you’ve managed to learn Excel macro programming, this should not be too complicated. Specifically, what you are looking for here is the if/else statement.

I've translated the first few cases of your first formula for you, you can now follow that pattern and add the remaining cases:

var v = this.getField("D11").value;

event.value = 0;

if (v == 0) {

  event.value = 0;

}

else if (v >=0 && v <= 50) {

  event.value = 16.25;

}

else if (v > 50 && v <= 100) {

  event.value = 31.5;

}

else if (...)

Here is a good resource to learn about JavaScript and Acrobat: Beginning JavaScript for Adobe Acrobat

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 29, 2016 Apr 29, 2016
LATEST

Looks good,

Thanks for the help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines