Formula to vba conversion

lesliewheeler

New Member
Joined
Dec 1, 2016
Messages
32
Office Version
  1. 2013
Platform
  1. Windows
Hi

I have the below 2 formulas

formula in cell D3 =VLOOKUP(B3,$R$1:$T$37,2,0) - This is pasted in cell D3 right down to D1000001

formula in cell E3 =IF(B3=0,"LOSS",IF(OR(VALUE(D3)=(VALUE(LEFT(C2,1))),VALUE(D3)=VALUE(RIGHT(C2,1))),"HIT","LOSS"))- This is pasted in cell E3 right down to E1000001

Can anyone help me with the VBA code for these 2 formula.

Thank You.
 

Excel Facts

Wildcard in VLOOKUP
Use =VLOOKUP("Apple*" to find apple, Apple, or applesauce
Hi there. A really low-tech but effective solution is: record a macro filling down from row 3 to row 10000001, and then run it each time you need it
 
Upvote 0
Hi there. A really low-tech but effective solution is: record a macro filling down from row 3 to row 10000001, and then run it each time you need it
This pastes the formula copied in macro recording, so it wont solve the purpose as the file is getting heavy due to formulas
 
Upvote 0
This pastes the formula copied in macro recording, so it wont solve the purpose as the file is getting heavy due to formulas
I see "VLOOKUP" and the mention of a lot of data, and it makes me believe that we may actually be dealing with a Relational Database.
If that is indeed the case, while you can try to use Excel for something like that, it can be rather clunky and inefficient (as you see).
Excel really wasn't designed for that purpose, so if you are truly trying to improve efficiency, it may be better to try to use a Relational Database program, such as Microsoft Access, SQL, or MySQL.

If using one of those tools is not an option for you, then perhaps you can do something like what jmacleary suggested, and after you run the code to insert those formulas, you can have your VBA code copy over the formulas with the values of those calculations (to "hard-code" the data). That will get rid of all those calculations after you calculate them, and should reduce the overhead.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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