Excel

TheSmallman.com

an XL ideas Lab

Dashboards VBA
  • Home
  • Dashboards
    • Tips & Tricks
    • Charts
    • Modelling
    • Infographics
    • VBA
  • Shop Dashboards
    • Power Pivot a User Guide
    • Excel Dashboard Course
    • Advanced Dashboard Course
    • Financial Modelling Course
    • Excel VBA Course
  • Blog
  • About
Menu

Excel Dashboards VBA

Street Address
City, State, Zip
Phone Number
an XL ideas Lab

Your Custom Text Here

Excel Dashboards VBA

  • Home
  • Dashboards
  • Excel Tips
    • Tips & Tricks
    • Charts
    • Modelling
    • Infographics
    • VBA
  • Shop Dashboards
  • PowerPivot
    • Power Pivot a User Guide
  • Courses
    • Excel Dashboard Course
    • Advanced Dashboard Course
    • Financial Modelling Course
    • Excel VBA Course
  • Blog
  • About

Evaluate with Excel to Extract Sequence

March 7, 2019 Marcus Small
Extract with Evaluate Excel

Of late I have been working with pulling data from cells and extracting the numbers between a series.  So if the data is presented like the following.

(2010-2015)

I want to see the following:

2010, 2011,2012, 2013, 2014, 2015


This post is very similar to the blog post from January which does the same sort of thing differently:

Extract with VBA

To do this we could create a custom function to pull the data from a cell in a neat and clean way.

Option Explicit

Function GetYr(txt As String) As String
Dim Var As Variant
      If txt Like "*-*" Then
               Var = Split(txt, "-")
               GetYr= Join(Evaluate("transpose(row(" & Var(0) & ":" & Var(1) & "))"), ", ")
     Else
            GetYr= Val(txt)
     End If
End Function

I prefer the extract method as it is cleaner and uses less coding to achieve a customised result.  Use the dash *-* as your delimiter, if you want to change it use your symbol in place of the dash.

Neat and clean result with a custom function drawing on the Evaluate function.

Neat and clean result with a custom function drawing on the Evaluate function.

Also if you wish to have a different data separator then change the following;

Years = Join(Evaluate("transpose(row(" & Var(0) & ":" & Var(1) & "))"), ", ")

Where  ", "

The end needs to change if you wished to use for example the dash then the code would look as follows.

Years = Join(Evaluate("transpose(row(" & Var(0) & ":" & Var(1) & "))"), "- ")

Where "- "

Is the part you change.  Hope this is clear.

The below file shows the coding in action.  Hope this provides more clarity.

Evaluate.xlsm







Tags Evaluate, Excel, Number Sequence
← Convert Entire Excel Workbook to ValuesExtract the First Item from a Horizontal List →

Featured Posts

Excel Dashboards: Tracking a Crisis

Excel Dashboards: Tracking a Crisis
April 14, 2020

Recent Posts

Populating an Excel Table from a Range of Cells with VBA

Populating an Excel Table from a Range of Cells with VBA June 12, 2025

Fuzzy Distribution with Randbetween

Fuzzy Distribution with Randbetween May 21, 2025

Add Minimum and Maximum for Chart in Cells

Add Minimum and Maximum for Chart in Cells March 12, 2025

Inflation Over Multiple Years in a Single Cell

Inflation Over Multiple Years in a Single Cell January 10, 2025

Hubspot Dashboard

Hubspot Dashboard October 3, 2024

Monthly Dashboard With Supporting Metrics

Monthly Dashboard With Supporting Metrics September 25, 2024

Excel Show Missing Sheet Tabs

Excel Show Missing Sheet Tabs July 29, 2024

Run Macro Overnight Automatically

Run Macro Overnight Automatically June 24, 2024

Split File into Parts and Save to Directory

Split File into Parts and Save to Directory April 20, 2024

Most Popular Author

Most Popular Author December 14, 2023

 

Follow US:

 
 

MarcusSmall@thesmallman.com

 

TheSmallman.com - Making your small systems hum...
© Copyright 2013-2024 theSmallman.com All Rights Reserved.