• 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
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member
  • Login

Data Validation Formula for EXACT TEXT, CAPITAL LETTERS no spaces before or after|General Excel Questions & Answers|Excel Forum|My Online Training Hub

You are here: Home / Data Validation Formula for EXACT TEXT, CAPITAL LETTERS no spaces before or after|General Excel Questions & Answers|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
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 ForumGeneral Excel Questions & Answe…Data Validation Formula for EXACT T…
sp_PrintTopic sp_TopicIcon
Data Validation Formula for EXACT TEXT, CAPITAL LETTERS no spaces before or after
Avatar
Gayla MS

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
March 23, 2019
sp_UserOfflineSmall Offline
1
March 23, 2019 - 9:39 pm
sp_Permalink sp_Print

I am looking for a way for only specific text to be entered into a cell - the cell to only accept CAPITAL letters and no leading or following spaces.

Let's say these cells can only have 2 characters / some I have will have 3 or 4 Words.

I need the cell to accept only GM, GA, KA, LA, PA not  GA<SPACE>, GM<SPACE> , KA<SPACE>

(If a space is put behind the letters then when I am writing formulas with SumIF(s) then it will not pick up information from the cells with the space.

 

I have tried writing a formula to drop in Data Validation but it will not accept my formula   =OR(exact(A1)="GM",exact(A1)="GA")

 

I am at my witts end 🙁Confused

Avatar
Anders Sehlstedt
Eskilstuna, Sweden

VIP
Members


Trusted Members
Level 3
Forum Posts: 880
Member Since:
December 7, 2016
sp_UserOfflineSmall Offline
2
March 24, 2019 - 3:16 am
sp_Permalink sp_Print

Hello,

There is a blog article written by Mynda that should help you forward. Check this out.
https://www.myonlinetraininghu.....it-entries

Br,
Anders

Avatar
Gayla MS

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
March 23, 2019
sp_UserOfflineSmall Offline
3
March 24, 2019 - 6:37 pm
sp_Permalink sp_Print

Thank you. But this did not help.

I cannot find anything that will give me what I need.... :(.

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
4
March 24, 2019 - 10:04 pm
sp_Permalink sp_Print

Hi Gayla

You mentioned:

Let's say these cells can only have 2 characters / some I have will have 3 or 4 Words.

Did you mean 3 or 4 characters or words?

Are the characters manually entered or selected from a drop-down list?

Sunny

Avatar
Anders Sehlstedt
Eskilstuna, Sweden

VIP
Members


Trusted Members
Level 3
Forum Posts: 880
Member Since:
December 7, 2016
sp_UserOfflineSmall Offline
5
March 25, 2019 - 12:30 am
sp_Permalink sp_Print sp_EditHistory

Hello Gayla,

Well, it's true that the article did not give a specific answer on how to get what you want, but it surely gives some hints to get you further on.
Anyway, paste in this formula in the Data Validation custom criteria. Of course do needed changes.

=AND(ISTEXT(A1),EXACT(A1,UPPER(A1)),LEN(A1)=2)

What this formula does is the following:
1) ISTEXT(A1) --> Checks if the data in cell A1 is text, if so then it gives the value of TRUE, else FALSE.
2) EXACT(A1,UPPER(A1)) --> Checks if the text in cell A1 is in upper case or not, if uppercase then it gives the value of TRUE, else FALSE.
3) LEN(A1)=2 --> Checks if the number of characters is two, if so then it gives the value of TRUE, else FALSE.

The AND() function just combines so that all three criterias are TRUE. If anyone of the above checks gets a FALSE value then the AND() function will give a FALSE value and then the data criteria is breached and the user gets an error message.
But with this solution you can not have a cell containing several words. If you need that then remove the LEN() criteria.

Br,
Anders

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


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

Hi Anders

I think you will also need to check A1 for leading and trailing space.

So another criteria is LEN(TRIM(A1))=2

Sunny

Avatar
Anders Sehlstedt
Eskilstuna, Sweden

VIP
Members


Trusted Members
Level 3
Forum Posts: 880
Member Since:
December 7, 2016
sp_UserOfflineSmall Offline
7
March 25, 2019 - 6:36 am
sp_Permalink sp_Print

Hello Sunny,

Unfortunately the TRIM() function in a data validation does not do the actual job on the cell content. If you type in a space as first or last character, that space character remains but the criteria of only two characters length has passed as true, as the TRIM() function did of course trim out the space in the criteria check.

So I left it out using only LEN(A1)=2, so if you then try to write <space>GA in cell A1 it will result in a FALSE result, so the user gets an error message.

I do think that a VBA solution would be the best one for this scenario, but I am not good at writing VBA.

Br,
Anders

Avatar
SunnyKow
Puchong, Malaysia

VIP
Members


Trusted Members
Level 8
Forum Posts: 1432
Member Since:
June 25, 2016
sp_UserOfflineSmall Offline
8
March 25, 2019 - 9:14 am
sp_Permalink sp_Print sp_EditHistory

Hi Anders

I was referring to this:

=AND(ISTEXT(A1),EXACT(A1,UPPER(A1)),LEN(A1)=2,LEN(TRIM(A1))=2)

or even this

=AND(ISTEXT(A1),EXACT(A1,UPPER(A1)),LEN(A1)=2,LEN(A1)=LEN(TRIM(A1)))

It would compare the length before and after trimming.

Sunny

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1549
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
9
March 25, 2019 - 10:17 am
sp_Permalink sp_Print

Your data validation formula could be

=EXACT(B2,VLOOKUP(B2,E2:E6,1))

with the cell you are typing into being B2 and the permitted list of inputs in E2:E6.

See attached.

Phil

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 688
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
10
March 25, 2019 - 6:43 pm
sp_Permalink sp_Print

As a matter of interest, why are capital letters important? SUMIF(S) wouldn't care about case.

Avatar
Gayla MS

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
March 23, 2019
sp_UserOfflineSmall Offline
11
March 29, 2019 - 10:07 pm
sp_Permalink sp_Print

Velouria said
As a matter of interest, why are capital letters important? SUMIF(S) wouldn't care about case.  

I say all Caps because that is the way that Management wants it on the report.  For what reason????

Avatar
Gayla MS

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
March 23, 2019
sp_UserOfflineSmall Offline
12
March 29, 2019 - 10:12 pm
sp_Permalink sp_Print

SunnyKow said
Hi Gayla

You mentioned:

Let's say these cells can only have 2 characters / some I have will have 3 or 4 Words.

Did you mean 3 or 4 characters or words?

Are the characters manually entered or selected from a drop-down list?

Sunny  

These letters are manually typed in to cells.  The are group of letters such as SL  BD  LTR  STR EXE PRO SPEC

Avatar
Anders Sehlstedt
Eskilstuna, Sweden

VIP
Members


Trusted Members
Level 3
Forum Posts: 880
Member Since:
December 7, 2016
sp_UserOfflineSmall Offline
13
March 30, 2019 - 2:49 pm
sp_Permalink sp_Print

Philip Treacy said
Your data validation formula could be

=EXACT(B2,VLOOKUP(B2,E2:E6,1))

with the cell you are typing into being B2 and the permitted list of inputs in E2:E6.

See attached.

Phil  

Hello,

To me it seems that Phil’s suggestion is what would suite you the best.

Br,

Anders

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Nicholas Meyer
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 880
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 237
Jessica Stewart: 219
A.Maurizio: 213
Aye Mu: 201
jaryszek: 183
Newest Members:
Herbie Key
Trevor Pindling
Stevan Kanjo
Erin Sheldon
Nikita Bhatia
Sheilah Taylor
Clare Webber
David Jenssen
Dominic Brosnahan
Young You
Forum Stats:
Groups: 3
Forums: 24
Topics: 6526
Posts: 28576

 

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

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel Office Scripts
  • 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

Sign up to our newsletter and join over 400,000
others who learn Excel and Power BI with us.

 

Company

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

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.