VB to replace formula, please?

tjak

Board Regular
Joined
Jan 2, 2003
Messages
117
I have to split a downloaded report to 6 people based on a matrix. I have a 6-level, nested and/if formula, but it doesn't work in a module. Even if it did, I'm sure there are better ways to do this, but I don't know how. I get a lot of "expected end of statement" errors.
Any suggestions will be welcomed, but I ask that you comment them heavily as I'm trying to learn.

Thanx, again, to all.

Range("D2:d100").FormulaR1C1 = "=IF(AND(LEFT(rc[1],3)=""MED"", (rc[3])>2500),""1"",IF(AND(LEFT(RC[1],3) _
<>""MED"",(rc[3])>2500),""2"",IF(AND(LEFT(RC[1],3)=""MED"",(rc[-3])<""M""),""3"" _
,IF(AND(LEFT(RC[1],3)=""MED"",(rc[-3])>""L""),""4"",IF(AND(LEFT(RC[1],3)<>""MED"",(rc[-3])<""L"", _
""5"",""6"")))))"
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi

Worked through the formula (but not the logic) and found a mismatch with the brackets. Try

Code:
Range("D2:d100").FormulaR1C1 = "=IF(AND(LEFT(RC[1],3)=""MED"",RC[3]>2500),""1"",IF(AND(LEFT(RC[1],3)<>""MED"", RC[3]>2500),""2"",IF(AND(LEFT(RC[1],3)=""MED"", RC[-3]<""M""),""3"",IF(AND(LEFT(RC[1],3)=""MED"", RC[-3]>""L""),""4"",IF(AND(LEFT(RC[1],3)<>""MED"", RC[-3]<""L""),""5"",""6"")))))"


Tony
 
Upvote 0

Forum statistics

Threads
1,214,606
Messages
6,120,492
Members
448,967
Latest member
visheshkotha

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