• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Years (greater or less)|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Years (greater or less)|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosYears (greater or less)
sp_PrintTopic sp_TopicIcon
Years (greater or less)
Avatar
Bill Jone
Member
Members
Level 0
Forum Posts: 32
Member Since:
July 17, 2019
sp_UserOfflineSmall Offline
1
March 11, 2021 - 3:00 am
sp_Permalink sp_Print

Hello,

Please can you help me to compere two years as below.

Column A: contain one year only like 2018

Column B: Contain many years separated by | like 2015|2016|2020|1999

I want to add below flags in Column C.

Flag 1 :  Greater              "In case  Column A Greater than all values in Column B"

Flag 2 :  Less                   "In case  Column A less than all values in Column B"

Flag 3:   Equal                "In case  Column A Equal all values in Column B"

Please check below sample.

 

Year Relation Year Mentioned ?. Is A>B?
2020 2019|1999 Greater
2010 2014|2016|2018|2019 Less
2017 2017|2019 Equal
2020 2017|2018|2020 Equal
2020 2019|1999|2000|2003 Greater
2008 2016 Less

 

Thanks;

Bill

sp_AnswersTopicSeeAnswer See Answer
Avatar
Purfleet
England
Member
Members


Trusted Members
Level 4
Forum Posts: 412
Member Since:
December 20, 2019
sp_UserOfflineSmall Offline
2
March 11, 2021 - 7:55 am
sp_Permalink sp_Print

Does it have to be VBA? Attached is a very quick bodge before bed

Text to columns the years into D:I, then divided A by each split out year
then checked the number

Status column >
if 1 then Column A is Less than all the years in column B
if 0 then Column B is greater than all the years in column B
Anything else is either an exact or a mixture

As i say, quick and dirty, but might help

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 615
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
3
March 11, 2021 - 10:07 pm
sp_Permalink sp_Print

What if it's not greater than them all, less than them all, or equal to any of them? Eg you have 2017 in col A and 2016|2019 in column B?

Avatar
Bill Jone
Member
Members
Level 0
Forum Posts: 32
Member Since:
July 17, 2019
sp_UserOfflineSmall Offline
4
March 11, 2021 - 11:25 pm
sp_Permalink sp_Print

Hi Purfleet,

Thank you for fast reply.

Please can you update it by comparing the Column A with the the Highest year in Column B.

Ex:

Year Relation Year Mentioned ?. Status
2015 2014|2016|2018|2019 Less
2020 2017|2019 Greater
2016 2016|2016 Equal
2018 2018 Equal

 

Thanks;

Bill

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 615
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
5
March 12, 2021 - 12:45 am
sp_Permalink sp_Print

You could extract the max year with:

=MAX(INDEX(("0"&MID(B2,(ROW($1:$10)-1)*5+1,4))+0,))

into say C2 (assuming you never have more than 10 years in one cell). Then you can use a simple if formula like:

=IF(A2>C2,"Greater",IF(A2<C2,"Less","Equal"))

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
6
March 12, 2021 - 1:38 am
sp_Permalink sp_Print

If the years are sorted with the max on the right, you can also try:

=IF(A2>RIGHT(B2,4)+0,"Greater",IF(A2<RIGHT(B2,4)+0,"Less","Equal"))

sp_AnswersTopicAnswer
Answers Post
Avatar
Bill Jone
Member
Members
Level 0
Forum Posts: 32
Member Since:
July 17, 2019
sp_UserOfflineSmall Offline
7
March 12, 2021 - 6:37 am
sp_Permalink sp_Print

Thanks a lot, all of you

 

Thanks;

Bill

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Ruth Savage, Andy Kirby, Roy Lutke, Jeff Krueger
Guest(s) 8
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
John Chisholm
vexokeb sdfg
John Jack
Malcolm Toy
Ray-Yu Yang
George Shihadeh
Naomi Rumble
Uwe von Gostomski
Jonathan Jones
drsven
Forum Stats:
Groups: 3
Forums: 24
Topics: 6212
Posts: 27236

 

Member Stats:
Guest Posters: 49
Members: 31889
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.