If cell begins with within a forumla

nihad

New Member
Joined
Feb 24, 2021
Messages
28
Office Version
  1. 365
Platform
  1. Windows
Hi

I'm using Indirect forumla to give values from different tabs which works perfectly, my search criteria is column R

how do I add a formula to say if cell in column R begins with number 4 then multiple by -1 else just return with value

Company budget Lee S.xlsx
DEFGHIJKLMNOPQR
3Oct NovDecJanFebMarAprMayJunJulAugSepTotalNameNominal
40000000000000Head Office 1014100
50000000000000Head Office 1014300
64,4743,4214,4743,1584,4746,0531,8425,0005,2632,63204,21145000Head Office 1015000
GP Import
Cell Formulas
RangeFormula
D4:D6D4=INDEX(INDIRECT("'" &$Q4 &"'!C1:C200"),MATCH($R4,INDIRECT("'" &Q4 &"'!B1:B200"),0))
E4:E6E4=INDEX(INDIRECT("'" &$Q4 &"'!D1:D200"),MATCH($R4,INDIRECT("'" &Q4 &"'!B1:B200"),0))
F4:F6F4=INDEX(INDIRECT("'" &$Q4 &"'!E1:E200"),MATCH($R4,INDIRECT("'" &Q4 &"'!B1:B200"),0))
G4:G6G4=INDEX(INDIRECT("'" &$Q4 &"'!F1:F200"),MATCH($R4,INDIRECT("'" &Q4 &"'!B1:B200"),0))
H4:H6H4=INDEX(INDIRECT("'" &$Q4 &"'!G1:G200"),MATCH($R4,INDIRECT("'" &Q4 &"'!B1:B200"),0))
I4:I6I4=INDEX(INDIRECT("'" &$Q4 &"'!H1:H200"),MATCH($R4,INDIRECT("'" &Q4 &"'!B1:B200"),0))
J4:J6J4=INDEX(INDIRECT("'" &$Q4 &"'!I1:I200"),MATCH($R4,INDIRECT("'" &Q4 &"'!B1:B200"),0))
K4:K6K4=INDEX(INDIRECT("'" &$Q4 &"'!j1:j200"),MATCH($R4,INDIRECT("'" &Q4 &"'!B1:B200"),0))
L4:L6L4=INDEX(INDIRECT("'" &$Q4 &"'!k1:k200"),MATCH($R4,INDIRECT("'" &Q4 &"'!B1:B200"),0))
M4:M6M4=INDEX(INDIRECT("'" &$Q4 &"'!l1:l200"),MATCH($R4,INDIRECT("'" &Q4 &"'!B1:B200"),0))
N4:N6N4=INDEX(INDIRECT("'" &$Q4 &"'!m1:m200"),MATCH($R4,INDIRECT("'" &Q4 &"'!B1:B200"),0))
O4:O6O4=INDEX(INDIRECT("'" &$Q4 &"'!n1:n200"),MATCH($R4,INDIRECT("'" &Q4 &"'!B1:B200"),0))
P4:P6P4=SUM(D4:O4)
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
64,052
Office Version
  1. 365
Platform
  1. Windows
How about
Excel Formula:
=INDEX(INDIRECT("'" &$Q4 &"'!C1:C200"),MATCH(IF(LEFT($R4)="4",$R4*-1,$R4),INDIRECT("'" &Q4 &"'!B1:B200"),0))
 

nihad

New Member
Joined
Feb 24, 2021
Messages
28
Office Version
  1. 365
Platform
  1. Windows
How about
Excel Formula:
=INDEX(INDIRECT("'" &$Q4 &"'!C1:C200"),MATCH(IF(LEFT($R4)="4",$R4*-1,$R4),INDIRECT("'" &Q4 &"'!B1:B200"),0))

Returns with #NA

sorry I don't think I was very clear, I meant the returned value in D4 to be multiplied by -1 if R4 begins with "4"

Thanks
 
Last edited:

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
64,052
Office Version
  1. 365
Platform
  1. Windows
Ok, how about
Excel Formula:
=IF(LEFT($R4)="4",-1,1)*INDEX(INDIRECT("'" &$Q4 &"'!C1:C200"),MATCH($R4,INDIRECT("'" &Q4 &"'!B1:B200"),0))
 

nihad

New Member
Joined
Feb 24, 2021
Messages
28
Office Version
  1. 365
Platform
  1. Windows
yay that worked

thank you very much.
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
64,052
Office Version
  1. 365
Platform
  1. Windows
You're welcome & thanks for the feedback.
 

Forum statistics

Threads
1,144,528
Messages
5,724,857
Members
422,586
Latest member
nassardewa

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
Top