Convert Excel formula to VBA code

Shiva_sss

New Member
Joined
Nov 20, 2023
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hi,

This is the excel formula that I need in VBA code. Would appreciate if someone could help me convert this formula into a VBA code. Thank you.

=IFNA(VLOOKUP(LEFT(S2,7)&BA2&BE2,'filepath/Workbook/Sheet1'!$D$4:$E$1048576,2,FALSE),IFNA(VLOOKUP(LEFT(S2,7)&BA2&BE2,'filepath/Workbook/Sheet2'!$E$3:$G$1048576,3,FALSE),IF(OR(MID(S2,3,1)="P",
LEFT(S2,3)="RHS"),"Option1","Option2")))
 

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.
Start by inserting the formula into a cell on a worksheet. (make sure that the formula works; resolves to a solution.)
START the macro recorder.
Press F2 (this puts the cell into Edit mode)
Press enter, this writes the VBA code into the macro recorder.
STOP the macro recorder.
Examine the resulting VBA code that was written with the recorder in the VBA IDE; should contain VBA equivalent of the formula.
 
Upvote 0

Forum statistics

Threads
1,215,713
Messages
6,126,412
Members
449,314
Latest member
MrSabo83

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