Help converting formulas

cspengel

Board Regular
Joined
Oct 29, 2022
Messages
173
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
So I have a formula that I am trying to convert as the number of columns could change, but I have them represented as "lFirstHTeamCol" and "lLastHTeamCol"

Formula 1: =IFERROR(INDEX(Table2[@[MVP15]:[FLEX19]],MODE(IF((Table2[@[MVP15]:[FLEX19]]<>"")*(Table2[@[MVP15]:[FLEX19]]<>INDEX(Table2[@[MVP15]:[FLEX19]],MODE(IF(Table2[@[MVP15]:[FLEX19]]<>"",MATCH(Table2[@[MVP15]:[FLEX19]],Table2[@[MVP15]:[FLEX19]],0))))),MATCH(Table2[@[MVP15]:[FLEX19]],Table2[@[MVP15]:[FLEX19]],0)))),"")

The above formulas intention is to show the second most common repeated text. Turning the formula into VBA gives me:

.Formula2R1C1 = "=IFERROR(INDEX(RC[-13]:RC[-5],MODE(IF((RC[-13]:RC[-5]<>"""")*(RC[-13]:RC[-5]<>INDEX(RC[-13]:RC[-5],MODE(IF(RC[-13]:RC[-5]<>"""",MATCH(RC[-13]:RC[-5],RC[-13]:RC[-5],0))))),MATCH(RC[-13]:RC[-5],RC[-13]:RC[-5],0)))),"""")"

Now I just need [-13] to be replaced with lFirstHTeamCol and [-5] to be replaced with lLastHTeamCol.

I really struggle with the quotation marks and what not. Thanks for any assistance.

This is the formula I use for the most common occurrence to give an idea of what I am trying to do:

.FormulaR1C1 = "=INDEX(RC" & lFirstHTeamCol & ":RC" & lLastHTeamCol & ",MODE(MATCH(RC" & lFirstHTeamCol & ":RC" & lLastHTeamCol & ",RC" & lFirstHTeamCol & ":RC" & lLastHTeamCol & ",0)))"
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
I've Tried this, but it is not returning anything. It also gives no errors.

VBA Code:
.FormulaR1C1 = "=IFERROR(INDEX(RC" & lFirstHTeamCol & ":RC" & lLastHTeamCol & ",MODE(IF((RC" & lFirstHTeamCol & ":RC" & lLastHTeamCol & "<>"""")*(RC" & lFirstHTeamCol & ":RC" & lLastHTeamCol & "<>INDEX(RC" & lFirstHTeamCol & ":RC" & lLastHTeamCol & ",MODE(IF(RC" & lFirstHTeamCol & ":RC" & lLastHTeamCol & "<>"""",MATCH(RC" & lFirstHTeamCol & ":RC" & lLastHTeamCol & ",RC" & lFirstHTeamCol & ":RC" & lLastHTeamCol & ",0))))),MATCH(RC" & lFirstHTeamCol & ":RC" & lLastHTeamCol & ",RC" & lFirstHTeamCol & ":RC" & lLastHTeamCol & ",0)))),"""")"
 
Upvote 0

Forum statistics

Threads
1,215,068
Messages
6,122,950
Members
449,095
Latest member
nmaske

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