Excel Tips, Tricks, Cheats & Hacks – Readers Edition

Share

Facebook
Twitter
LinkedIn

Over the last month we have seen some 52, Excel Tips, Tricks, Cheats & Hacks presented by some of the best Excel practitioners on the net:

Excel Tips, Tricks, Cheats & Hacks – Microsoft MVP Edition

Excel Tips, Tricks, Cheats & Hacks – Chandoo.org Excel Ninja Edition

Excel Tips, Tricks, Cheats & Hacks – Notable Excel Sites Edition

Excel Tips, Tricks, Cheats & Hacks – Readers Prequil

 

In this final post I am presenting a compilation of Readers Contributions.

These have been compiled from comments on the above 4 posts and submissions sent directly to me.

I hope you enjoy the following Excel Tips, Tricks, Cheats & Hacks – Readers Edition

 

001. Toggle the Absolute/Relative $ Sign in Formulas using F4 – Desk Lamp

Instead of typing $AA$12 simply type AA12 then press F4.

Press F4 to Toggles through the sequence: AA12 -> $AA$12 -> AA$12 -> $AA12 -> AA12

Abs Rel Address

You can read about Absolute vs Relative Cell References here

 

002. Current Region – Peter Carr

My favorite tip is the CurrentRegion of a range.

CurrentRegion is the contiguous range of cells starting from a cell, and moving out in all directions until an entire blank row or column is reached.

EHRO08

The current Region of the Yellow Cell above is the Red Outlined Area

Keyboard
From the keyboard you can do this by pressing Ctrl+* or Ctrl+A, which is a shortcut for GoTo, Special, Current Region.

VBA

In VBA you can use the Range.CurrentRegion property

If there is a block of data in B4:F10 with blank rows & columns around it

Dim myRange  as Range

myRange = Range(“C8”).CurrentRegion

will set myRange to $B$4:$F$10

To identify the number of rows in a contiguous region.
e.g. intNumberOfRows = Range(“FirstCell”).CurrentRegion.Rows.Count

003. Select the Current Region using the QAT – Christine

In addition to the techniques described by Peter above, you can select the Current Region by adding an Icon to the Quick Access Toolbar.

EHRO06

Click on any cell and then click on the icon or use Alt+4

 

004. Find the Alt-Shortcut Key Number for the QAT – Hui

In the “Select the Current Region using the QAT” post above, Christine showed us how to use the Current Region Icon CurrentRegionIcon to quickly select the current Region. But how do we know it is the 4th Icon?

The Alt Number is Position dependent, in the example above the Current Region Icon is the 4th Icon from the Left in the QAT and so it is accessed by Alt+4

But by simply pressing the Alt key, Excel will show you the shortcut numbers for the QAT and all other Tabs

Alt_Keyboard Shortcuts

So we can see that the Select the Current Region icons is yes, No 4 and so Alt+4 is required to activate it

We can also see that the Record a Macro icon is number 08. To use that You use Alt+08 (Using the Number keys, not the numeric keypad)

Using Alt also shows you all the Tab shortcuts as well

 

005. Stay on the Current Cell after you press Enter – MF

Typically when entering data as you press the Enter key, Excel advances the current cell to the next cell as defined in the File, Options, Advanced, Editing Options menu

To stay on the current cell Simply press Ctrl+Enter instead of Enter

You can set your default move direction or disable Move Selection permanently by changing the option in the File, Options, Advanced, Editing Options menu:

EHRO01

 

006. Close a File Shortcut – Johnathan Cooper

Simply pressing Ctrl+W closes the current file

If the file has changed since the last save you are given the option to Save the file before it closes

 

007. Keyboard Shortcuts – Chirayu

Hide columns – CTRL + 0
Apply Filter (alternative) – SHIFT + CTRL + L
Clear Filter – ALT + D + F + S
Drag Down – CTRL + D
Drag Right – CTRL + R
Drag Up – ALT + E + I + U
Drag Left – ALT + E + I + L
Value Paste – ALT + E + S + V
Format Paste – ALT + E + S + T

You can find a comprehensive list of Keyboard Shortcuts at: Chandoo.org Keyboard Shortcuts

 

008. Use AutoCorrect to write formula – Wynn Hopkins

My favorite trick is using AutoCorrect to help write INDEX MATCH formulas..

Copy the following line into AutoCorrect and then use iii as the text to replace

=INDEX( DblClk_to_Select_Column_to_return, MATCH( DblClk_Single_Lookup_Cell, DblClk_Lookup_Column, 0),0)

This way whenever you need INDEX MATCH you just type iii and AutoCorrect kicks in and you are 3 double clicks away from a robust formula.

AutoCorrect is found in the File, Options, Proofing Menu

EHRO02

Contributor: Wyn Hopkins

 

009. Fill Blanks in a Data Table before use in a Pivot Table – RobD

When building pivot tables, it helps to have a full column of like values, so if you have a set up such as:

Where the data area has blank cell

EHRO03a

Use this handy VBA

EHRO03b

‘Change the MyCol value to match your value

Becomes…

EHRO03c

Note: The code copies the text above the blank cell, and so the user must be careful that this is a valid assumption

 

010. Fill Blanks in a Data Table before use in a Pivot Table II – Jomili

Extending the technique shown above, Jomili supplied some VBA code that does the same as 007 above, except that it handles Multiple Columns at once as well as allowing Formulas to be converted to Values in the final result

So

EHRO04a

becomes

EHRO04b

by using this code:

EHRO04d

011. QAT Copy/Paste Shortcut – Ian Watkins

By assigning the Copy, Paste Values and Paste Formulas Icons to positions 1, 2 & 3 of the Quick Access Toolbar

Instead of doing a big move of my hand from Ctrl+C to Alt+2, I can just move a finger from Alt+1 t copy

Click on the new cell and press Alt+2 or Alt+3 without moving my hand

EHRO05

Speeds things up quite a bit!

 

012. Customize Markers in a Chart – Chandeep

Customizing markers in a chart – http://www.goodly.co.in/customize-markers-in-a-chart/

 

013. Charting Hacks to work faster – Chandeep

Charting Hacks to work faster – http://www.goodly.co.in/5-charting-hacks-to-help-you-work-faster/

 

014. Seven Date formulas to make life easy – Chandeep

7 Date formulas to make life easy – http://www.goodly.co.in/date-formulas-in-excel/

 

015. Customised scrollbar using VBA – Chandeep

Customised scrollbar using VBA – http://www.goodly.co.in/customized-scroll-bar-in-excel/

 

016. Adding Direct Legends – Chandeep

Adding Direct Legends – http://www.goodly.co.in/how-to-add-direct-legends-to-the-chart/

 

017. Excel Ninja Menu – Krishna Khemraj

Select a cell or range then move till the 4-way cross appears.

Then Right-Click and drag the selection to another place in the worksheet then, like a ninja, a menu full of skills and throwing stars pops up allowing me to do all kinds of awesomeness.

EHRO06a

When you click the fill box on a Date and Right Click and Drag it down, a lot of amazing Date options pop up.

EHRO06b

 

018. Copy & Paste Filtered Data Only – Patricia

If you try to copy subtotaled data (and in earlier Excel versions filtered data), when you paste it all the data displays instead of just the summarized data.
To get around this, select your summarized data, click on Find and Select tab and then select Go to Special.

Click Visible cells Only and click Ok.

Now paste and you will see that only the summarized data has been copied.
You can also go CTRL+G and then click the Special icon at the bottom of the dialog box.

 

019. Clear Filters for the Current Column – Graham

With a table that is filtered, ensure the active cell is in the header of a filtered column and hit ALT + Down Arrow + C to clear the filter for the current column

 

020. Names Formula Tips – Pedro Paulo

You can bring up the Name Manager in Excel by pressing Ctrl+F3.

This lists the names used in your current workbook, and you can also define new names, edit existing ones or delete names from the Name Manager.

You can define several named ranges using data that’s arranged in neat tables. Excel creates named ranges from your selection and uses your data headings as the new names.

Make sure your data has headings (top row, left column, bottom row or right column) as these will turn into the names of your named ranges
Select the data including headings, press Ctrl+Shift+F3, in the dialog box select where your headings are (top row, left column, bottom row or right column) and click Ok.

Field Names which include spaces will be replaced with underscores

eg: Account Code will become the Account_Code named formula

 

021. Avoid Division by Zero – Ian Wilson

If a formula returns a number value, the Iferror() function can be used to isolate a returned value of zero.

You just need to utilize reciprocals:
1/(1/x) = x, however, if x = 0, then the function is an error.
My most common use of this feature is to return a blank instead of a 0.
=iferror(1/(1/sum(range)),””)
This could also be used to avoid division by 0 or replace 0s with a string.

 

022. Text to Columns Shortcut – Vishal Onkar

When working with lots of Text or CSV Files you invariably end up using the Text to Columns function repeatedly

This can be accessed by the ALT+D+E  keyboard shortcut

023. Convert a Month in Words to a Month Number – Denys calvin

To convert a month in words (i.e., “August”) to its number (i.e., “8”), use, at least, the first three letters of the word in the following formula: =MONTH(“mmm”&1)

=Month(“March”&1) returns 3

=Month(“Mar”&1) returns 3

 

024. Trace Precedent/Dependents – Prashant99

Trace precedent cells Ctrl+[
Trace dependent cells F5+Enter or Ctrl+]

 

025. Resize Columns – Target

I routinely get sheets with data all smashed up which I hate and I’ve never been able to find a shortcut to do this.

To get around this I use the following VBA and assign a shortcut key (CTRL+Q)

EHRO07

It can be a nuisance if I’ve intentionally hidden columns, but the convenience far outweighs the inconvenience

 

026. Format Table Header Row – Ronnie

I use Tables many times a day and have a simple macro to give me a consistent Table format

EHRO09b

The VBA Code:

EHRO09aaa

027. Quickly Jump to Range – Efand

Type the range address directly in the Name Box and then press Enter to select it.

e.g: type A3:A6 will select its ranges without using any clicking and dragging

EHRO10a

 

If you select a Range say B3:B6, then type a Name in the Name Box “From_Date“, Excel sets up a Named Formula referring to that range

EHRO10b

If the Named Formula already exists, eg: From_Date, Typing From_Date into the box will take you to it.

You can also use the Drop Down next to the Name Box to select existing Named Ranges

EHRO10b2

 

028. Easily delete all Non-Formula cells – Martin

To easily delete all none-formula entries in a worksheet in one go:

Goto Home, Find & Select, Constants

This selects all cells that do not contain a formula.

Then just hit the delete button and you are done!

 

029. Reset all Cell Comments to the Same Style – Hui

To Reset all Cell Comments to the Same Style simply copy this code into a code module in your workbook

Edit the style parameters to suit your need

Run the code with F5

EHRO11b

 

Closing

Many many thanks to the Microsoft Excel MVPs, Chandoo.org Ninja’s & My Favorite Excel Websites Authors for the 52 and You for the 29 Excel Tips, Tricks, Cheats & Hacks that have been showcased over these past 5 posts.

I hope you get to to revue all the tips and pass comments and appreciation back to the authors as appropriate.

I will re-run this series in May 2017 so keep a list of your new Excel Tips, Tricks or Hacks handy.

If you have any Excel Tips, Tricks or Hacks, Don’t be afraid to share them below in the comments:

 

 

Facebook
Twitter
LinkedIn

Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week.

Learn & be awesome.

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME.

Read my storyFREE Excel tips book

Overall I learned a lot and I thought you did a great job of explaining how to do things. This will definitely elevate my reporting in the future.
Rebekah S
Reporting Analyst
Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

40 Responses to “Looking up when the data won’t co-operate (case study)”

  1. Sumit Bansal says:

    Nice Trick.. Clever use of cell references

    Here is a formula I tried to create:
    =SUMPRODUCT(((NOT(ISERROR(SEARCH(L5,B4:H14))))*1),(B5:H15))

    It takes care of Caveat #1 (can handle text), but Caveat #2 remains.

  2. PeterB says:

    In situations like this, I will often use VBA to restructure the data (2 columns: dates and values) on to a new worksheet. I can then use this 'clean' source for data analysis (formula or pivot table).

    =SUMPRODUCT(((NOT(ISERROR(SEARCH(L5,B4:H14))))*1),(B5:H15)) and complex formulae in general are all very well but when you come back to them in a few weeks / months time, it is not at all easy to see what they do and what the limitations are.

  3. Somendra Misra says:

    Hi Chandoo,

    I had used this type of cell ref. various times while calculating average.
    But for the situation here try below formula . Note this is an array formula and must be confirmed with Ctrl+Shift+Enter.

    =SMALL(IF(MMULT((L5=B4:H14)*IF(ISNUMBER(B5:H15),B5:H15),{1;1;1;1;1;1;1}),MMULT((L5=B4:H14)*IF(ISNUMBER(B5:H15),B5:H15),{1;1;1;1;1;1;1})),1)

    Regards,

  4. Somendra Misra says:

    Hi, I think Using SEARCH in here will create a problem say there is a text like SUN and another text SUNLIGHT both result will be added by SUMPRODUCT.

    Regards,

  5. Elias says:

    Array option.

    =SUM(IF(MOD(ROW(B4:B14),2)=MOD(ROW(B4),2),IF(B4:H14=L5,B5:H15)))

    Regards

    • Michael (Micky) Avidan says:

      @Elias,
      Nice approach.
      Although not requested - the formula I suggested closes all possibilities.
      Criteria: _____ Value to retrieve:
      Date__________ Numeric
      Date__________Textual
      Textual________Numeric
      Textual________Textual
      While your formula copes with only the 3 first combinations.
      Michael (Micky) Avidan
      “Microsoft® Answer” – Wiki author & Forums Moderator
      “Microsoft®” MVP – Excel (2009-2015)
      ISRAEL

      • Elias says:

        @Michael,

        Sorry but I don’t understand your point. I believe the challenge was to return the summary of a given date. What is your really volatile formula doing that mine is not?

        Regards

        • Michael (Micky) Avidan says:

          @Elias,
          I didn't say that the challenge differs from what you just mentioned/aimed to nor that your formula doesn't provide the requested result.
          Please read my previous comment again and focus on the last combination (TEXT / TEXT).
          I, myself, always try to provide a global Formula that is capable to handle all sorts of data.
          Michael (Micky) Avidan
          “Microsoft® Answer” – Wiki author & Forums Moderator
          “Microsoft®” MVP – Excel (2009-2015)
          ISRAEL

          • Elias says:

            @Michael,
            I see your point, but you are missing the below points if you are trying to cover all sorts of data.

            What happened if the lookup value does not exist?

            Do you want the first, second, summary, concatenation of the values if the look value is repeated?

            See they are too many possibilities to be cover with just one formula.

            Regards

  6. Michael (Micky) Avidan says:

    1) The range: B4:H15 was named: RNG.
    2) The following Array Formula was "retrieved from my sleeve" and I hope it can be shorten.
    3) The formula seems to take care of BOTH(!) caveats.
    -------------------------------------------------------------------------------
    =OFFSET(INDIRECT(ADDRESS(SMALL(IF(RNG=L5,ROW(RNG),""),1),MOD(SMALL(IF(RNG=L5,(ROW(RNG))+COLUMN(RNG)/10),1),1)*10)),1,)
    -------------------------------------------------------------------------------
    Michael (Micky) Avidan
    “Microsoft® Answer” – Wiki author & Forums Moderator
    “Microsoft®” MVP – Excel (2009-2015)
    ISRAEL

    • Elias says:

      @Michael,

      Check what happened with your result if you type 41927 in D5.

      Regards

      • Michael (Micky) Avidan says:

        Correct. Didn't predict that.
        Will find time to work something out.
        Michael (Micky) Avidan
        “Microsoft® Answer” – Wiki author & Forums Moderator
        “Microsoft®” MVP – Excel (2009-2015)
        ISRAEL

      • Michael (Micky) Avidan says:

        @Elias,
        Let's hope the following Array Formula "closes all open doors".
        Again - it has nothing to do with your formula which works fine as long as the 3 first mentioned combinations are concerned.
        -------------------------------------------------------------------------------
        =INDEX(RNG,LARGE(IF(RNG=L5,MOD(ROW(RNG)-1,2)*(ROW(RNG)),""),1)-2,(MOD(SMALL(IF(RNG=L5,(ROW(RNG))+COLUMN(RNG)/10),1),1)*10)-1)
        -------------------------------------------------------------------------------
        Michael (Micky) Avidan
        “Microsoft® Answer” – Wiki author & Forums Moderator
        “Microsoft®” MVP – Excel (2009-2015)
        ISRAEL

        • Elias says:

          Ok, if you insist. The following will cover all the scenarios you listed. However, I’ll never recommend/use such of formula.

          Defined names:
          rDat = $B$4:$H$15
          rRow =ROW(rDat)-MIN(ROW(rDat))+1
          rCol =COLUMN(rDat)-MIN(COLUMN(rDat))+1
          rInc =MOD(rRow,2)=MOD(MIN(rRow),2)

          L6=INDEX(rDat,MAX(IF(rInc,IF(rDat=L5,rRow)))+1,MAX(IF(rInc,IF(rDat=L5,rCol))))
          Array Enter

          Regards

        • Frank says:

          @Michael,

          unfortunately, your array formula still seems to return wrong results (eg 3-Nov).

  7. Magda says:

    If data are organized like in the example, ie. looks like a calendar, the INDEX formula seems quite simple:
    =INDEX($B$4:$H$15,ROUNDDOWN((L5-B4)/7,0)*2+2,MOD((L5-B4),7)+1)

    • Marc says:

      Yours is effectively the same as what I just came up with, and I believe this is the optimal answer to this particular problem.

      My solution, before I saw yours:
      =OFFSET(B5,QUOTIENT(L5-B4,7)*2,MOD(L5-B4,7))

      OFFSET will work for an arbitrary list size, but INDEX might be easier to read.
      QUOTIENT does the round and division in a single step.

  8. XOR LX says:

    If there's an improvement over Elias's solution then I for one can't see it.

    Perhaps a non-CSE version which would also mean that only two references (B4:H14 and B5:H15), as opposed to three (B4, B4:B14 and and B5:H15), would require manually amending should the data range change, i.e.:

    =SUMPRODUCT((ISEVEN(ROW(B4:H14)-MIN(ROW(B4:H14)))*(B4:H14=L5)*B5:H15))

    I suppose we could make it a single, uniform range reference:

    =SUMPRODUCT((ISEVEN(ROW(B4:H14)-MIN(ROW(B4:H14)))*(B4:H14=L5)*OFFSET(B4:H14,1,,,)))

    which might be more appropriate should we e.g. wish to use a Defined Name for our range, i.e.:

    =SUMPRODUCT((ISEVEN(ROW(Rng)-MIN(ROW(Rng)))*(Rng=L5)*OFFSET(Rng,1,,,)))

    though whether that compensates for the extra, volatile function call is something to be debated.

    Regards

  9. Mahir says:

    I have tried something and then my Excel workbooks got shut down. Maybe that was too much?

    Anyway here is what I've tried:

    =SUMPRODUCT(INDEX(B5:H15;IF(ISEVEN(ROW(B5:H15));ROW(B5:B15)-ROW(B5)+1);{1\2\3\4\5\6\7}))

    Guess that was wrong? Would this approach work anyway?

    Looking forward to learn something from you Excel Experts.

  10. XOR LX says:

    @Michael Avidan

    As it stands that is not a very rigorous construction.

    You say "I, myself, always try to provide a global Formula that is capable to handle all sorts of data", which is a wonderful philosophy, but isn't it at least as important that we ensure that our formulas are independent of the row and column references of the data range in question, so that, should that range change, we do not have to re-work our solution?

    What happens with your formula, for example, if RNG is instead re-located one row down, from B4:H15 to B5:H16?

    When a formula is reliant upon the addition/subtraction of certain constants within the formula, which themselves are necessarily dependent upon the specific rows/columns in which the data lies at any given time (e.g. the -1 in MOD(ROW(RNG)-1,2)), then that formula is not a very flexible one.

    Hence the reason for my choice of a slightly longer construction:

    ROW(B4:H14)-MIN(ROW(B4:H14))

    which ensures that this part of the calculation is not dependent upon the precise location of the data range within the worksheet, and so will give correct answers even if that range is re-located.

    Regards

  11. Haz says:

    {=OFFSET(B4,MAX((B4:H15=L5)*ISODD(ROW(1:12))*ROW(1:12)),MAX((B4:H15=L5)*ISODD(ROW(1:12))*COLUMN(A:G))-1)}

    • Haz says:

      Non-array formula:
      =INDEX(B4:H15,SUMPRODUCT((B4:H15=L5)*(ROW(B4:H15)-ROW(B4)+1)*ISODD(ROW(B4:H15)-ROW(B4)+1))+1,SUMPRODUCT((B4:H15=L5)*(COLUMN(B4:H15)-COLUMN(B4)+1)*ISODD(ROW(B4:H15)-ROW(B4)+1)))

      Using one range (B4:H15), one reference (B4), one lookup value (L5) and no INDIRECT or OFFSET.

  12. MF says:

    My trial with defined names:

    DateRange
    =$B$4:$H$4,$B$6:$H$6,$B$8:$H$8,$B$10:$H$10,$B$12:$H$12,$B$14:$H$14

    Position
    =RANK('lookup problem'!$L$5,DateRange,1)

    L6
    =OFFSET(B4,ROUNDUP(Position/7,0)*2- 1,IF(MOD(Position,7)=0,6,MOD(Position,7)-1))

  13. Jeff Weir says:

    I'd probably just run with something like:
    =SUMPRODUCT((B4:H14=L5)*(MOD(ROW(B4:H14),2)=MOD(ROW(B4),2))*B5:H15)
    ...which is basically the same as Elias' but without the IFs

  14. Bermir says:

    The opposite of elegant but it works...

    =INDEX(B4:H15,IFERROR(MATCH(L5,B4:B14,0),0)+IFERROR(MATCH(L5,C4:C14,0),0)+IFERROR(MATCH(L5,D4:D14,0),0)+IFERROR(MATCH(L5,E4:E14,0),0)+IFERROR(MATCH(L5,F4:F14,0),0)+IFERROR(MATCH(L5,G4:G14,0),0)+IFERROR(MATCH(L5,H4:H14,0),0)+1,IFERROR(MATCH(L5,B4:H4,0),0)+IFERROR(MATCH(L5,B6:H6,0),0)+IFERROR(MATCH(L5,B8:H8,0),0)+IFERROR(MATCH(L5,B10:H10,0),0)+IFERROR(MATCH(L5,B12:H12,0),0)+IFERROR(MATCH(L5,B14:H14,0),0))

    • Bermir says:

      =INDEX(B4:H15,
      IFERROR(MATCH(L5,B4:B14,0),0)+
      IFERROR(MATCH(L5,C4:C14,0),0)+
      IFERROR(MATCH(L5,D4:D14,0),0)+
      IFERROR(MATCH(L5,E4:E14,0),0)+
      IFERROR(MATCH(L5,F4:F14,0),0)+
      IFERROR(MATCH(L5,G4:G14,0),0)+
      IFERROR(MATCH(L5,H4:H14,0),0)+1,
      IFERROR(MATCH(L5,B4:H4,0),0)+
      IFERROR(MATCH(L5,B6:H6,0),0)+
      IFERROR(MATCH(L5,B8:H8,0),0)+
      IFERROR(MATCH(L5,B10:H10,0),0)+
      IFERROR(MATCH(L5,B12:H12,0),0)+
      IFERROR(MATCH(L5,B14:H14,0),0))

  15. HF says:

    Named Range
    rownum = SUMPRODUCT(('lookup problem'!$B$4:$H$14='lookup problem'!$L$5)*ROW('lookup problem'!$B$4:$H$14)*ISEVEN(ROW('lookup problem'!$B$4:$H$14)))

    Formula
    =OFFSET($A$1,rownum,MATCH(L5,INDIRECT("$B"&rownum&":$H"&rownum),0))

  16. Venky says:

    How about SUM(IF(B4:H14=L5,B5:H15)) with array..it should work

  17. xen says:

    Sorry, Chandoo, you can't find stuff this way in every possible scenario.
    What if 2014-10-01 sales would equal 41.927 ? Which is serial number for 2014-10-15 ? SUMIF would fail to retrive correct answer. And your example data suggest that such number is possible in your table.

    It's better not to search through dates and numbers at the same time.

    If I'd solve a problem like this, it'd reformat table first so I get one column with dates and the other with numbers.

    In this case, formula to form date column would be:
    =INDIRECT(ADDRESS((INT((ROW()-4)/COUNT($B$4:$H$4))+1)*2+2;MOD(ROW()-4;COUNT($B$4:$H$4))+2;4;1))
    and numbers would be the same formula with sight adjustment (+3 instead of +2 at the end of first argument):
    =INDIRECT(ADDRESS((INT((ROW()-4)/COUNT($B$4:$H$4))+1)*2+3;MOD(ROW()-4;COUNT($B$4:$H$4))+2;4;1))

    And now you got two columns that you can safely use for searching!

  18. xen says:

    Oops, sorry, you actually mentioned that it doesn't work if number=date! I missed that part 🙁

  19. Vad says:

    ={OFFSET(A1,SUM((B4:H14=L5)*ROW((B4:H14))),SUM((B4:H14=L5)*COLUMN((B4:H14)))-1)}

    Works for all data... the solution I got for indirect looks little lengthy

  20. Rajesh says:

    I want to count last 20 records of a person, whose marks is greater than 2 and grade "manager". ....

    Assume A1 has got names (James, John...etc...)
    A2 "Manager"

    A3 "2"

    Someone please reply

  21. Rajesh says:

    I want to count last 20 records of a person, whose marks is greater than "2" and grade "Manager"

    Assume A1 "geroge" A2 "Michael" A3 "George" etc...name can found anywhere in the rows

    B1 "Manager" B2" clerk"

    C1 "2" C2, "4"

    please reply

  22. Marc says:

    Simplest I can come up with. No limitations for either 1 or 2. This does assume dates are an ordered list with 7 per row, and 2 rows per set. Assuming this is always true this will work for an arbitrary long list of dates.

    =OFFSET(B5,QUOTIENT($L$5-$B$4,7)*2,MOD($L$5-$B$4,7))

    • Michael (Micky) Avidan says:

      @Marc,
      Nice approach - however, as there are no "Negative Dates" - try:
      =OFFSET(B5,INT(L5-B4)/7)*2,MOD(L5-B4,7))
      ——————————————————————————-
      Michael (Micky) Avidan
      “Microsoft® Answer” – Wiki author & Forums Moderator
      “Microsoft®” MVP – Excel (2009-2015)
      ISRAEL

  23. Vijaykumar Shetye says:

    =OFFSET(B4,ROUNDUP((L5-41911+1)/7,0)*2-1,MOD(L5-41911,7))

    B4 has been used as reference cell for OFFSET().

    FOR ROWS:
    ROUNDUP(....,0) gives the integer value of a division. In case of presence of a remainder, ROUNDUP will add 1 to the Quotient.
    As opposed to ROUNDUP(), the INT() or QUOTIENT() functions eliminate the remainder.

    41911 = 01-Sept-2014, the first date in the data.

    *2 has been used because there are 2 columns per set of data.

    /7 has been used because there are 7 columns per set of data.

    For columns
    MOD(L5-41911,7))

    Vijaykumar Shetye,
    Panaji, Goa, India

  24. Awais says:

    This is how i did it

    {=INDEX(B4:H15, MAX((L5=B4:H15)*ROW(B4:H15))-2, MAX((L5=B4:H15)*COLUMN(B4:H15))-1 )}

  25. Paul says:

    Here's my solution:

    =INDEX(B4:H15,MATCH(1,MMULT(--(B4:H15=L5),TRANSPOSE(COLUMN(B4:H15)^0)),0)+1,MATCH(1,MMULT(TRANSPOSE(--(B4:H15=L5)),ROW(B4:H15)^0),0))

Leave a Reply