Excel Speedup & Optimization Tips by Experts [Speedy Spreadsheet Week]

Share

Facebook
Twitter
LinkedIn

As part of Speedy Spreadsheet Week, I have emailed a few renowned Excel experts and asked them to share their tips & ideas to speedup Excel. Today, I am glad to present a collection of the tips shared by them.

Excel Speedup & Optimization Tips by Experts

Excel Speeding up & Optimization Tips by Hui

About Hui:
Hui (Ian Huitson) has been writing & contributing to Chandoo.org for more than 2 years. Many of you know him from Formula Forensics & Data table related articles on Chandoo.org. See about Hui page for more about him.

In no particular order:

  • Minimize the use of Volatile Functions
  • Organize your workbook layout and data methodically
  • Where possible use fixed values or Named formulas instead of lookups even if the values only change rarely, flag those for manual checking
  • Don’t Start equations with a + that actually adds 0.4% calculation time
  • Minimize use of the Data Table command to running summaries only at the end of a project
  • Review the logic of the model and all if’s or lookup choices for necessity or alternatives
  • Use negatives instead of multiple positives where appropriate in conjunction with If’s and Lookups
  • Learn about Conjunctive Truth Tables, they Rock for reporting
  • Array formulas can do the work of dozens of normal cells, but use cautiously
  • Use Named Formulas and UDF’s instead of multiple Helper Cells/Rows or Columns
  • Minimize of us Conditional Formatting
  • Minimize use of linked workbooks especially if over network drives
  • Take an advanced Excel course like the ExcelHero Academy
  • Minimize the use of Excel 2007

Links:

Excel Speeding up & Optimization Tips by George

About George:
George runs Excel Unusual, where you can learn about using Excel for engineering, simulations & games. In his work, he builds complex spreadsheet models all the time. So I asked him to share a few tactics with us. He wrote 2 articles in response to my request.

Links:

Excel Speeding up & Optimization Tips by Gregory

About George:
Gregory runs Excel Semipro, where he shares Excel tips & ideas. I asked him to contribute to the Speedy Spreadsheet Week. This is what he says,

Tips by George:

To speed up my worksheet files, I have one primary rule: do not use the OFFSET function, which is volatile and can slow things down considerably. In newer spreadsheets I use Tables and The imposing INDEX function to keep ranges automatically updated. In Excel 2003 I use an event-based approach, with named ranges, the worksheet deactivate module, and VBA to keep lists and ranges updated.

Links:

Excel Speeding up & Optimization Tips by Luke

About Luke:
Luke is one of the Excel Ninjas at Chandoo.org where he contributed more than 1000 posts. I asked Luke to share some optimization tips based on his vast experience of using Excel & helping others. This is what he suggests:

  1. In VB, whenever I see a line like Selection.something that’s usually an indicator that I’m using extra lines. Either I need to apply the method directly to the object instead of selecting it, or I need to use a With statement.
  2. With Event macros, don’t forget the all-important lines of Application.EnableEvents = False and Application.EnableEvents = True so that you don’t cause multiple events to be triggered.
  3. See a section of code that you’re repeating? Probably need to make this a separate Sub or Function that you can then reference from the main code.
  4. When building your formula page, think top-down. Cells near the top of worksheet should be referenced in formulas that are below, not vice-versa. XL likes to calculate left to right, top to bottom. Scattering cell references around makes it work harder.
  5. When using large amounts of data that you want to be charted, sometimes I’ll build a formula sheet within the workbook with data, and then just build another workbook that uses a data query (referencing the formula results) to generate the charts.
  6. This might be more along the lines of auditing a worksheet, but sometimes it’s hard to see how I’ve laid out my constants and formulas, and using a worksheet map helps bring things into focus (related: create a worksheet map)

Want to become better in Excel? Join Chandoo.org courses

Excel School

Learn Excel from basics to advanced level. Create awesome reports, dashboards & workbooks.

Click here to know more

VBA Classes

Learn VBA & Macros step-by-step. Build complex workbooks, automate boring tasks and do awesome stuff.

Click here to know more

Excel Speeding up & Optimization Tips by Narayan

About Narayan:
Narayan is one of the Excel Ninjas at Chandoo.org where he contributed more than 1000 posts. I asked Narayan to share some optimization tips based on his vast experience of using Excel & helping others. This is what he suggests:

Period-to-Date and Cumulative SUMs
There are two methods of doing period-to-date or cumulative SUMs. Suppose the numbers that you want to cumulatively SUM are in column A, and you want column B to contain the cumulative sum; you can do either of the following:
You can create a formula in column B such as =SUM($A$1:$A2) and drag it down as far as you need. The beginning cell of the SUM is anchored in A1, but because the finishing cell has a relative row reference, it automatically increases for each row.
You can create a formula such as =$A1 in cell B1 and =$B1+$A2 in B2 and drag it down as far as you need. This calculates the cumulative cell by adding this row’s number to the previous cumulative SUM.
For 1,000 rows, the first method makes Excel do about 500,000 calculations, but the second method makes Excel do only about 2,000 calculations.

Subtotals

Use the SUBTOTAL function to SUM filtered lists. The SUBTOTAL function is useful because, unlike SUM, it ignores the following:
Hidden rows that result from filtering a list. Starting in Excel 2003, you can also make SUBTOTAL ignore all hidden rows, not just filtered rows.
Other SUBTOTAL functions.

Using SUMPRODUCT to Multiply and Add Ranges and Arrays.
In cases like weighted average calculations, where you need to multiply a range of numbers by another range of numbers and sum the results, using the comma syntax for SUMPRODUCT can be 20 to 25 percent faster than an array-entered SUM.
{=SUM($D$2:$D$10301*$E$2:$E$10301)}
=SUMPRODUCT($D$2:$D$10301*$E$2:$E$10301)
=SUMPRODUCT($D$2:$D$10301,$E$2:$E$10301)

These three formulas all produce the same result, but the third formula, which uses the comma syntax for SUMPRODUCT, takes only about 77 percent of the time to calculate that the other two formulas need.

Dynamic Ranges

These are most often created using the OFFSET and COUNTA functions , as in the following :
=OFFSET(Sheet1!$A$1,0,0,COUNTA(Sheet1!$A:$A)-1,1)

Sometimes , when data is stored in the form of records , so that all columns have data to the same extent , there may be several dynamic ranges ; say we have ORDER_ID in column A , CUSTOMER_ID in column B , and the AMOUNT in column C. Thus there may be several dynamic ranges as follows :
=OFFSET(Sheet1!$A$1,0,0,COUNTA(Sheet1!$A:$A)-1,1)
=OFFSET(Sheet1!$B$1,0,0,COUNTA(Sheet1!$B:$B)-1,1)
=OFFSET(Sheet1!$C$1,0,0,COUNTA(Sheet1!$C:$C)-1,1)

These can be simplified to :
=OFFSET(Sheet1!$A$1,0,0,COUNTA(Sheet1!$A:$A)-1,1)
=OFFSET(Sheet1!$B$1,0,0,COUNTA(Sheet1!$A:$A)-1,1)
=OFFSET(Sheet1!$C$1,0,0,COUNTA(Sheet1!$A:$A)-1,1)

These can then be optimized by storing the COUNTA value in a cell , and using the cell reference within the OFFSET formula :
=OFFSET(Sheet1!$A$1,0,0,Sheet1!$F$1,1)
=OFFSET(Sheet1!$B$1,0,0, Sheet1!$F$1,1)
=OFFSET(Sheet1!$C$1,0,0, Sheet1!$F$1,1)

Where Sheet1!$F$1 contains the formula : =COUNTA(Sheet1!$A:$A)-1
For more, refer to MSDN.

Resetting the USED RANGE

Pressing CTRL END will take the cursor and place it on the cell which Excel thinks is the last used cell in the worksheet.
Suppose you do this , and the cursor lands on D27 ; now navigate to any cell which is as far away as you can imagine , say AA3456 ; enter any character , even a space will do ; then clear the cell contents by pressing the DEL key.
Pressing CTRL END will now take the cursor to AA3456.
To reset the USED RANGE , go to the Immediate Window of the VBA Project , and enter the following statement :
Application.ActiveSheet.UsedRange
Your used range should now be reset to its earlier value of D27 ; pressing CTRL END will now take the cursor to D27.
Refer to this Stackoverflow discussion for more.

Excel Speeding up & Optimization Tips by Jordan

About Jordan:
Jordan runs Option Explicit, an Excel VBA blog. He shared these tips with us,

  • When reading and writing to ranges, use .value2 (this is noticeable for large, iterative calculations)
  • Ensure that ALL spreadsheet errors are handled. The most common errors I see ignored are #Ref errors and #Div (for dividing by zero). Use Go To Special… to find these errors and either delete them or use IFERROR to handle them. In my opinion, Excel errors are one of the biggest contributing factors to slow spreadsheets.
  • When using INDEX, include the row or column number even if you don’t need it. For example, if I’m pulling data from only one column, I need only write =INDEX(A1:A10, 1) to pull the first item. However, =INDEX(A1:A10, 1, 1) appears to be a hair faster. Try it.
  • Cut down on Lookup functions. In many instances, the lookup table has already encoded information in the correct order. Instead of looking up, say, Stage 2, just use INDEX on the desired column and pull from row 2.

Thanks to Hui, George, Gregory, Luke, Narayan & Jordan

Many thanks to all of you for sharing these ideas & tips so that we can speed up Excel. If you found these tips useful, say thanks to the contributors.

More on Excel Optimization & Speeding up:

Read these articles too,

Want to become better in Excel? Join Chandoo.org courses

Excel School

Learn Excel from basics to advanced level. Create awesome reports, dashboards & workbooks.

Click here to know more

VBA Classes

Learn VBA & Macros step-by-step. Build complex workbooks, automate boring tasks and do awesome stuff.

Click here to know more

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.

43 Responses to “Quickly convert numbers stored as text [tip]”

  1. Chandu says:

    Additional tip,

    Select column which contains text -> Data -> Data tools -> Text to columns -> Finish

    Chandu

    • Christy T says:

      This one is particularly awesome if you have tens of thousands of data to convert to number. Otherwise it can take excel forever (minutes to half hour or longer) to process an error correction.

    • Chris says:

      This is definitely the best option, and has the added benefit that you can use it to convert text to numbers, and numbers to text, depending on whether you choose General or Text before clicking Finish!

    • target says:

      when you use this method it's worth making sure that there are no delimiters selected (just in case)

      another method is to do a find & replace (I routinely use zero with zero, or . with .)

    • Sunder says:

      ALT+A+E>>enter>>enter will do it 🙂

    • S Unter says:

      OMG Thank you Chandu! I was struggling with this so much with my big datasheets and now I am so happy! so funny.
      In my excel though, it is the same pattern but it is:
      1) Choose the data tab
      2) highight the column you want to change
      3) choose "text to columns" in the ribbon
      4) select fixed width
      5) enter
      6) no crashes!!

    • Graham says:

      Often the text which you want as a number will have a decimal point, so Select column which contains text -> Data -> Data tools -> Text to columns ->Select apostrophe to add also as the delimiter -> Goto Advanced and add the decimal point. -> Finish, Voila. It works. You can then format as currency etc. Worked in Ver 2013. Seems that MS is degrading some important functions so as to get users to upgrade to 365.

  2. SAURABH says:

    Sir, how convert text to number in Power Query.

  3. Chris Macro says:

    I had never thought about multiplying the numbers by 1 before. Great tip. For those who love macros, I found a very well written VBA macro by Ejaz Ahmed (StrugglingToExcel.com). This macro not only converts the numerical text to numbers but also formats dates and trims the values (getting rid of those nasty leading/trailing spaces). Plus you can apply this to multiple columns at the same time! I immediately added it to my QAT bar and use it almost daily with my data extracts. Check it out!

    http://www.thespreadsheetguru.com/the-code-vault/2014/8/21/convert-numbers-stored-as-text

  4. Sue says:

    This tip is awesome! But one thing I run into constantly is the need to convert text to number and keep the leading zero, if there is one. I work a lot with SSNs and zip codes, etc. Any help, much appreciated!!

    • SAURABH says:

      Hi Sue,

      let ur zip code (length 5) in Column B, then select Column B and go to 'Format Cell' (CTRL + !) - Number - Custom - enter 00000 in Type field.

      Now put, 15 in cell B1 and it will show 00015.

      Hope this will solve ur query.

    • steffan says:

      1) SSNs and ZIP codes are not numeric. They are meant to be character based identifiers. With numbers, leading zeros to the left of the decimal are not significant and are truncated. It may sound terribly picky of me to bring up the distinction, but I've learned that it does make a difference in some cases. (Especially when delivering to a client who is attempting to extract and then load your data into a different DBMS.)

      2) The option described by SAURABH below (custom format, 00000) will work in Excel but it's only displaying the number as '00015' while the actual value of the cell will still be 15 because you have converted it to a number and excel will pay attention to significant digits (see above.) Meaning, if you "Paste special" with values only into a new cell, it will paste '15' into the cell rather than '00015', which could lead to problems depending upon how you need to carry them into new work. Your client's ETL process may bring in '15' rather than what you intend '00015.' I usually leave SSNs and ZIP as text, that way leading zeros (and dashes in the case of SSNs) are preserved.

  5. Jon Peltier says:

    Better than #2 (don't waste time dirtying and clearing a cell)... Copy a blank cell (really blank, not containing anything), select cells to change, Paste Special Values, Operation Add.

  6. Trouttrap2 says:

    An alternative to multiplying the numbers by 1 is to add 0 instead by using the same process as the multiplication method. At least you can save a step. You don't have to enter a 1 to multiply. The blank cell is 0 and can be added to change text to a number.

  7. indesignkat says:

    One thing I find very handy when doing this, as I often have intermittent numbers as text:

    Select the first cell that has the warning flag, then ctrl-down arrow to the last one. Once you have it all, especially if it's thousands of cells, it's annoying to scroll back up to get to the flag. If you apply formatting, such as setting the cell fill color to none, it automatically takes you back up to the top without losing your selection.

  8. Good Tips !
    I knew both the tips before. I like the tip mentioned by "Jon Peltier". Amazing + Awesome 🙂 He steals the Show .. I mean this Post 🙂 😉

    Thanks for contribution to all !

    Regards,
    Rahim Zulfiqar Ali

  9. Jeff Brown says:

    Love this post. I often have to export SAP Reports to excel and then do various sorts and lookups. This text issue has been driving me crazy. I especially like Jon Peltiers method where we can add a blank cell via paste special. Will be forwarding this tip to my friend Michael Martin.

    • Jeff Brown says:

      yes, Michael Martin was impressed!
      I also benefitted from Ctrl Alt V to paste special. I don't know how I have missed this one all these years. This is something we do a lot around here.

  10. sue says:

    Hi again! One reason I asked about the leading zero is not so much for display purposes. I realize that '15' formatted to '00015' still has a value of '15'. That is one of my issues!! I receive data from multiple sources and need to constantly do look-ups and queries, and I drive myself crazy trying to format the different spreadsheets so they can 'talk' to each other. Does anyone have a tried and true process for syncing up columns where numbers are stored as text? For me, it's SSN, personel number, and zip. And, I think some of the sources they ARE number and some (like our DB queries) come in as text. aaargh. And, thank you in advance.

    • steffan says:

      Ah, I see. I'd format anything ZIP or SSN related to text, and then clean up my lookup tables to be in that format as well. To convert those '15's back to '00015's there are two ways that I use.
      1) If I'm reformatting an entire workbook, I actually DO use the custom format to adjust some columns, like zip codes or dates in an unusual format (like '21 Aug 14', etc.) when I have everything like it needs to be, I save the result as a .CSV file. When excel saves a custom format as .CSV, it defaults to value (the display option) and discards value2 (the underlying actual value.) Text files have no record of formats, they are lean by their nature, so when you open it, Excel will attempt to interpret each column. Because of this, I close the CSV, and I use the text import wizard, (Data Tab > "From Text") to bring in the CSV. The import wizard lets me specify which columns I want to be Characters and which I want to be numbers, (and it does dates as well for good measure.)
      2) If I'm only able to reformat a single column, I'll usually do that via a Macro, for example, if the zip codes have had their zeros truncated by excel, I format that column as text, and run this "padding" macro that I wrote for that purpose:

      Sub Pad_to_X()
      On Error Resume Next
      'This will insert zeros in front of a number.
      'X is the length of the entire number plus zeros
      'so if you have 1 and want 001, X would be 3
      With Application
      .DisplayAlerts = False
      End With
      x = InputBox("Enter X, and the selection will be padded with leading zeros to X characters")
      For Each cell In Selection
      lenc = Len(cell)
      diff = x - lenc
      If diff > 0 Then
      padme = Empty
      For nn = 1 To diff
      padme = padme & "0"
      Next nn
      cell.Value = padme & cell.Value
      End If
      Next cell
      With Application
      .DisplayAlerts = True
      End With
      End Sub

      Cleaning data from multiple sources is fun. Often a lookup will bomb because the table or the dataset has characters that mean something to the client's software (or webpage,) but are "invisible" when you look at them in excel. In those cases, I recommend trimming leading and trailing whitespace, and looking for and removing chr(160) (HTML Non-Breaking whitespace.) Those are the most common.

      Sometimes the character in a cell is something you've never considered, and in the cases where a value isn't found in a lookup table, I'll run this "decode string" macro to split out the cell value and display it by its ASCII equivalent. It'll identify any weird relics, which you can then sweep for with a cleaning macro:

      Sub Decode_String()
      Dim sttrarray(1 To 5000) As Variant
      Dim sttrarray2(1 To 5000) As Variant
      'instring = InputBox("String to Decode?")
      instring = Selection.Value
      lenstring = Len(instring)
      count = 0
      For x = 1 To lenstring

      sttrarray(x) = Asc(Mid(instring, x, 1))
      sttrarray2(x) = Mid(instring, x, 1)
      count = count + 1
      Next x

      Workbooks.Add
      targ = ActiveWorkbook.Name
      sht = ActiveSheet.Name
      Workbooks(targ).Sheets(sht).Range("A1").Value = "Position"
      Workbooks(targ).Sheets(sht).Range("B1").Value = "Character"
      Workbooks(targ).Sheets(sht).Range("C1").Value = "ASCII decode"
      For n = 1 To count '

      Outp = Outp & "Position " & n & " is " & sttrarray2(n) & " or chr " & sttrarray(n) & Chr(13)
      Workbooks(targ).Sheets(sht).Range("A" & n + 1).Value = n
      Workbooks(targ).Sheets(sht).Range("B" & n + 1).Value = sttrarray2(n)
      Workbooks(targ).Sheets(sht).Range("C" & n + 1).Value = sttrarray(n)

      Next n
      End Sub

  11. MF says:

    Multiply 1, divided by 1, add or subtract 0 all do the trcik... ;p

  12. Santhosh Kunder says:

    Select the column and hit ALT+D+E and Finish till dialogue box disappears. We are good to go

  13. Rudra says:

    Instead of typing 1 and copying it, just copy any blank cell and go to paste special and add.

  14. Justas says:

    It happens that I need to attach some data from external source over and over again and the data comes in text format. If these procedures are too difficult, I use extra column to have values in numbers. The formula is very simple: =value()

  15. Belgianbrain says:

    You go from "sometimes text-numbers may be scattered across the worksheet, making selection of cells a pain." to "3. Select all the cells that have text-numbers."

    You just said it's a pain to select the cells... so you instruct us to do it anyway? Am I the only one who fails to see logic here?

    • Chandoo says:

      @Belgianbrain:

      You dont have to individually select such cells. you can select entire range that contains such data and do it. That is what I mean by "Select all the cells"

  16. Vitor Bruno Simei says:

    Good Tips! Thanks for sharing, very useful when SAP reports must be exported

  17. Faseeh says:

    Put zero in a cell >> Copy >> Paste Special >> Add

    ...will also do that.

  18. Subbu says:

    Awasome... Chandooo..

  19. Puneet Gogia says:

    But if data is too large u can use the Function =Value( & Then Use Paste Special.
    Else this trick is superb.

  20. ESG says:

    Love this website!!!!
    The "enter 0", copy - paste special - add method puts a zero in blank cells.
    Similarly, for the enter 1- copy paste special multiply.
    The copy blank - copy - paste special - add method does not seem to have this drawback.
    Thank you.

  21. JLeno says:

    If you do use the first option (click on 'Convert to number') and you're working in a large model, make sure you turn on the Manual calculation mode. Otherwise Excel will recalculate after each converted number. This can be really annoying if a model takes 0.1 seconds to recalculate and you just told Excel to convert a couple of thousand numbers!

    The Value() formula works fine as well, which is good for external data, or to be used in LOOKUP functions. The other way around, by the way, if you must LOOKUP a value and you're looking it up in an array of text values, I use =TEXT(A1,"0") to convert a value to its string equivalent.

    I also love the Add 0 tip, I hadn't thought of that!

  22. […] If you import data that has numbers formatted as text, Chandoo shares a quick tip for fixing them. […]

  23. Vignesh says:

    Really a useful tip,for me my users use SAP as input where often tedious to select all the cells and again go to the top row to convert numbsers.

    Really a very useful tip.

  24. Martrix says:

    To those keyboard people:
    To access this "error handling menu", press the Alt + Right Click Button, then press the "C" to convert to number... this last "C" is in portuguese, I dunno what the equivalent in english is.
    Also another thing I learned together with this trick. If you are using one of these new keyboard, that doesn't have a Right Click button, the equivalent to it is Shift + F10... so it would be Alt + Shift + F10 then "C"

  25. Celeste says:

    This tip (Tip#2: Paste Special Convert) saved my life! I've always done all my conversions the 1st way. Working across multiple sheets exported from my Accounting program, all the zeros are always listed as text. It was so frustrating - and then this tip came along! Thank you thank you thank you! I now just select all sheets, do the ctr+alt+v thing and voila! all text is now zeros!
    Very very useful tip 🙂

  26. Rocky Arora says:

    Chandoo Tu Bhai hai

  27. Srinivasan says:

    Thanks a lot

  28. Anup says:

    Hi All,
    I have few data with month as column name and Planned hours, forecast for months,actuals hours , ETC as Row data. What I want is whenever the user enter values in forecast month(Current month) , it shld color the cells.and when the user enter the values in Actuals hours(it will be of prevous month) it shld fill the color.The cycle will continue . Also As the month will pass on the previous valued cells shld be in no format.

  29. Aly says:

    My excel crashes to the point it is unusable. The only method I have found that wont crash my machine is find & replace (replace 1 with 1, and so on.) I am not sure what causes this in my sheets, and it can even cause another machine to start having this issue. I assume it is settings or the data itself. I created a dump file off the process before crashing, which ended up being huge. Looking in the file with notepad, some data I can't see. But towards the bottom of the file there is a ton of words - waiting on word wrap to finish in it to see what it says.

    • Hui... says:

      @aly

      a few things

      What type of PC is it?
      How much RAM?
      What version of Windows/Excel are you using ?

      Do you know how many lines of data you have ?

      Can you ask the question in the Chandoo.org Forums?
      https://chandoo.org/forum/

      Please attach the data file so we can give you more specific help

Leave a Reply