MATCH function return second result

thesnowplow

New Member
Joined
May 2, 2017
Messages
13
=OFFSET(Sheet1!$A$7,0,MATCH(Sheet1!$A$1,Sheet1!$B$6:$OI$6,0),200,1)

Formula I use as a named range for my chart series works perfectly. How do I modify it to return 2nd result as there are more than one matches that fit the criteria $A$1.
 
Actually, rather than leaving that column empty, it may be better to enter #N/A values for your range in that column.
 
Last edited:
Upvote 0

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I just tried and it worked. I will test it out on the real thing tomorrow at work but thank you very much for your help!

This will save massive amounts of time for generating multi graphs going forward.
 
Upvote 0
Hey man I want to give you an update as your help was incredible.

See picture attached, it's a chart sheet. Imgur: The most awesome images on the Internet

I combined your formulas and modified them with one more variable so I ended up with 2 drop down boxes, the second one is dynamic displaying all suppliers for each selected product. It works like magic. I can slice 400-500 columns with a click of a button and it doesn't require much maintenance from week to week.

Question: because my X axis is based on also a dynamic column, for it to display days properly 1 at a time I have to "Specify interval unit:" (in picture its 125). Is there a way to link that field through VBA perhaps to a cell A1 in Sheet1 for example? I tried googling but couldn't find anything..
 
Upvote 0
You can use a worksheet change event to automatically change the interval unit. So, let's say that cell A1 in Sheet1 will be used to specify the interval, and that the same sheet, Sheet1, contains the chart, right-click the sheet tab for Sheet1, and select View Code. Then paste the following code in the code module for the sheet...

Code:
[COLOR=darkblue]Option[/COLOR] [COLOR=darkblue]Explicit[/COLOR]

[COLOR=darkblue]Private[/COLOR] [COLOR=darkblue]Sub[/COLOR] Worksheet_Change([COLOR=darkblue]ByVal[/COLOR] Target [COLOR=darkblue]As[/COLOR] Range)
    [COLOR=darkblue]If[/COLOR] Target.Address <> "$A$1" [COLOR=darkblue]Then[/COLOR] [COLOR=darkblue]Exit[/COLOR] [COLOR=darkblue]Sub[/COLOR]
    [COLOR=darkblue]If[/COLOR] Len(Target) = 0 [COLOR=darkblue]Then[/COLOR] [COLOR=darkblue]Exit[/COLOR] [COLOR=darkblue]Sub[/COLOR]
    [COLOR=darkblue]If[/COLOR] [COLOR=darkblue]Not[/COLOR] IsNumeric(Target) [COLOR=darkblue]Then[/COLOR]
        Target.Select
        Target.ClearContents [COLOR=green]'optional[/COLOR]
        MsgBox "The interval must be a number.", vbInformation
        [COLOR=darkblue]Exit[/COLOR] [COLOR=darkblue]Sub[/COLOR]
    [COLOR=darkblue]End[/COLOR] [COLOR=darkblue]If[/COLOR]
    [COLOR=darkblue]If[/COLOR] Target.Value <= 0 [COLOR=darkblue]Then[/COLOR]
        Target.Select
        Target.ClearContents [COLOR=green]'optional[/COLOR]
        MsgBox "The interval must be a whole number greater than 1.", vbInformation
        [COLOR=darkblue]Exit[/COLOR] [COLOR=darkblue]Sub[/COLOR]
    [COLOR=darkblue]End[/COLOR] If
    Me.ChartObjects("Chart 1").Chart.Axes(xlCategory).TickLabelSpacing = Target.Value
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]

If your chart is located in another sheet, let's say Sheet2, replace...

Code:
Me.ChartObjects("Chart 1").Chart.Axes(xlCategory).TickLabelSpacing = Target.Value

with

Code:
Worksheets("Sheet2").ChartObjects("Chart 1").Chart.Axes(xlCategory).TickLabelSpacing = Target.Value

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,224,827
Messages
6,181,197
Members
453,021
Latest member
pingpong7117

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