VBA Code for excel formula

Vicasso

New Member
Joined
Sep 9, 2019
Messages
6
I have to include the below formula(IN BOLD) in a for loop of a vba code and compare with another cell with the same formula using IF ELSE Condition, but it keeps on throwing compile error.

=(VALUE(MID(A2,2,FIND(" ",A2)-2)))*IF(VALUE(MID(A2,SEARCH("through",A2)+8,1))>=4,4,VALUE(MID(A2,SEARCH("through",A2)+8,1)))

PFB the vba code i have written

ElseIf ( (VALUE(MID(x(10,j),2,FIND(" ",x(10,j))-2)))*( If (VALUE(MID(x(10,j),SEARCH("through",x(10,j))+8,1))) >= 4 Then 4 Else (VALUE(MID(x(10,j),SEARCH("through",x(10,j))+8,1)))) >

(VALUE(MID(Plan(x(4,j)& x(10,1)),2,FIND(" ",Plan(x(4,j)& x(10,1)))-2)))*( If(VALUE(MID(Plan(x(4,j)& x(10,1)),SEARCH("through",Plan(x(4,j)& x(10,1)))+8,1))) >= 4 Then 4 Else (VALUE(MID(Plan(x(4,j)& x(10,1)),SEARCH("through",Plan(x(4,j)& x(10,1)))+8,1)))))

Then wsCompetitor.Cells(10, j).Interior.Color = RGB(0, 255, 255)
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Hello,

To get a VBA ' translation' of your formula ...

Just turn on your macro recorder and input the formula ...

Hope this will help
 
Upvote 0

Forum statistics

Threads
1,215,771
Messages
6,126,799
Members
449,337
Latest member
BBV123

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