Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-18-2017, 11:50 PM
ArviLaanemets ArviLaanemets is offline Error trapping Windows 8 Error trapping Office 2016
Expert
 
Join Date: May 2017
Posts: 932
ArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant future
Default

A correct format will be like:
Forename, Surname, Title
John, Smith, Mr

To determine, which part in full name belongs to where is possible only, when there are certain rules how this full name is composed, and the number of those rules is limited, as you have to include all of them into every formula.

P.e.
1 When the full name doesn't have comma in it, then 1st part is may be title with possible values Mr/Ms/Mrs;
2.a. When the full name doesn't have comma in it, then 1st part after title is forename, and the rest is surname;
or
2.b. When the full name doesn't have comma in it, then last part is surname, and the rest except title is forename;
3. Otherwise at end of full name may be title. All before comma is surname, and all after comma and space except title is forname;

When these rules are always fulfilled, you can calculate all parts of name. To keep formulas length reasonable, I advice to use helper columns which you can hide later.
Title:
Code:
 
=IF(FIND(",",FullName)>0,
IF(RIGHT(FullName,3)=" Mr","Mr", IF(RIGHT(FullName,3)=" Ms","Ms",IF(RIGHT(FullName,4)=" Mrs","Mrs",""))),
IF(LEFT(FullName,3)="Mr ","Mr", IF(LEFT(FullName,3)="Ms ","Ms",IF(LEFT(FullName,4)="Mrs ","Mrs",""))))
NameWithoutTitle
Code:
 
=IF(FIND(",",FullName)>0,
IF(RIGHT(FullName,3)=" Mr", LEFT(FullName,LEN(FullName)-3), IF(RIGHT(FullName,3)=" Ms",LEFT(FullName,LEN(FullName)-3),IF(RIGHT(FullName,4)=" Mrs", LEFT(FullName,LEN(FullName)-4),FullName))),
IF(LEFT(FullName,3)="Mr ",RIGHT(FullName,LEN(FullName)-3), IF(LEFT(FullName,3)="Ms ",RIGHT(FullName,LEN(FullName)-3),IF(LEFT(FullName,4)="Mrs ",RIGHT(FullName,LEN(FullName)-4),FullName))))
ForeName:
Code:
 
=IF(FIND(",",FullName)>0,
RIGHT(NameWithoutTitle, LEN(NameWithoutTitle)-FIND(" ", NameWithoutTitle)),
LEFT(NameWithoutTitle, FIND(" ", NameWithoutTitle) -1)
etc.

PS. You have to check formulas, as I did write them on fly.
Reply With Quote
  #2  
Old 12-19-2017, 03:06 AM
Ricco49 Ricco49 is offline Error trapping Windows 10 Error trapping Office 2010 64bit
Novice
Error trapping
 
Join Date: Oct 2017
Posts: 7
Ricco49 is on a distinguished road
Default

Avril, thank you for such a quick response. I shall indeed try out your code; they have also given me an idea of something a long way back in my experience. :-)
Reply With Quote
  #3  
Old 12-20-2017, 11:14 AM
Ricco49 Ricco49 is offline Error trapping Windows 10 Error trapping Office 2010 64bit
Novice
Error trapping
 
Join Date: Oct 2017
Posts: 7
Ricco49 is on a distinguished road
Default

Avril,

Before trying the code on the Delegate field I had a go at Conditional formatting another field and then copy / pasting from an emailed spreadsheet.
The formatting did not work but it did when I typed into the cells.
Is there some bizarre format to data in an emailed document?

Ric

Quote:
Originally Posted by ArviLaanemets View Post
A correct format will be like:
Forename, Surname, Title
John, Smith, Mr

To determine, which part in full name belongs to where is possible only, when there are certain rules how this full name is composed, and the number of those rules is limited, as you have to include all of them into every formula.

P.e.
1 When the full name doesn't have comma in it, then 1st part is may be title with possible values Mr/Ms/Mrs;
2.a. When the full name doesn't have comma in it, then 1st part after title is forename, and the rest is surname;
or
2.b. When the full name doesn't have comma in it, then last part is surname, and the rest except title is forename;
3. Otherwise at end of full name may be title. All before comma is surname, and all after comma and space except title is forname;

When these rules are always fulfilled, you can calculate all parts of name. To keep formulas length reasonable, I advice to use helper columns which you can hide later.
Title:
Code:
 
=IF(FIND(",",FullName)>0,
IF(RIGHT(FullName,3)=" Mr","Mr", IF(RIGHT(FullName,3)=" Ms","Ms",IF(RIGHT(FullName,4)=" Mrs","Mrs",""))),
IF(LEFT(FullName,3)="Mr ","Mr", IF(LEFT(FullName,3)="Ms ","Ms",IF(LEFT(FullName,4)="Mrs ","Mrs",""))))
NameWithoutTitle
Code:
 
=IF(FIND(",",FullName)>0,
IF(RIGHT(FullName,3)=" Mr", LEFT(FullName,LEN(FullName)-3), IF(RIGHT(FullName,3)=" Ms",LEFT(FullName,LEN(FullName)-3),IF(RIGHT(FullName,4)=" Mrs", LEFT(FullName,LEN(FullName)-4),FullName))),
IF(LEFT(FullName,3)="Mr ",RIGHT(FullName,LEN(FullName)-3), IF(LEFT(FullName,3)="Ms ",RIGHT(FullName,LEN(FullName)-3),IF(LEFT(FullName,4)="Mrs ",RIGHT(FullName,LEN(FullName)-4),FullName))))
ForeName:
Code:
 
=IF(FIND(",",FullName)>0,
RIGHT(NameWithoutTitle, LEN(NameWithoutTitle)-FIND(" ", NameWithoutTitle)),
LEFT(NameWithoutTitle, FIND(" ", NameWithoutTitle) -1)
etc.

PS. You have to check formulas, as I did write them on fly.
Avril, one thing I tried on the text data fields
Reply With Quote
  #4  
Old 12-21-2017, 12:11 PM
Ricco49 Ricco49 is offline Error trapping Windows 10 Error trapping Office 2010 64bit
Novice
Error trapping
 
Join Date: Oct 2017
Posts: 7
Ricco49 is on a distinguished road
Default

Still having no joy with this - I feel so dense!

I am trying a simpler approach first on some copy/pasted data;
eg Sales, Finance, Marketing, Services

I want to check for any imported data that contains errors such as typos or incorrect depts. I tried a Conditional Format rule for one of the words and it worked.

However, as soon as I added further rules for the other words the whole thing fell apart.

Can anyone point me in the right direction? I have tried formulae with AND as well as OR but nothing works.
Reply With Quote
  #5  
Old 12-21-2017, 12:43 PM
ArviLaanemets ArviLaanemets is offline Error trapping Windows 8 Error trapping Office 2016
Expert
 
Join Date: May 2017
Posts: 932
ArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant future
Talking

I'm not sure I understand exactly, what you did. And I'm not sure you understood exactly, what I adviced.

My advice was, to calculate a new field based on entry you got from other sources. I.e. you get some names as single text column, and the formulas split this single-column name to components, which you can use in your tables as they are, or you compose a stadardized full name column based on those. The formulas itself were an example, how to split non-standard full name for one hypothetical set of rules. You have to determine, which set of rules can be applied on your data, and to design formulas according them.

As you talk about conditional formatting, it looks like you try to use latter to indicate entries, which need editing. When so, then:
1. when you can design formulas for conditional formatting, showing faulty entries, then you always can design formulas to split entries too;
2. when you can design formulas to split entries, it doesn't always mean, you can design similar formulas for conditional formatting. Conditional Formatting has some limitations;
3. When you use conditional formatting, then you have manually edit all marked entries. When you split original entries and compose standard name, this work is not needed.

About coping data from web into excel - this is a path for disaster. Web resources often don't use conventional character set. P.e. they can use some unicode characters, which look like normal letters, but are coded differently. And databases and spreadsheets don't operate with character images - they operate with character codes. So when you read a character "A" from web, it may be not same as character "A" you typed into cell from keyboard. And for Excel, p.e. two seemingly identical words "And" and "And" may be entirely different (don't check on what I typed here).
Reply With Quote
  #6  
Old 12-22-2017, 01:10 AM
Ricco49 Ricco49 is offline Error trapping Windows 10 Error trapping Office 2010 64bit
Novice
Error trapping
 
Join Date: Oct 2017
Posts: 7
Ricco49 is on a distinguished road
Default

Hello, Avril. My apologies - I did understand your advice on the splitting of the name field, I was going for one of the easier fields first. There are four division fields and I was trying to create a check for typos. I can get a formula [COLOR="Purple"](=IF(AND(J2<>"Automotive/LLP",J2<>"Retail",J2<>"Supply Chain",J2<>"Consumer, EM",J2<>"Life Sciences"),"Error","")[/COLOUR] to work but it means setting up four extra columns to report the errors (one column for each check) and my wife doesn't want this. I tried the formula in the appropriate part of a conditional format but it wouldn't work there.
You have confirmed my suspicion that the data in an email or SMS is different. Perhaps this isn't going to work at all. I have recommended that their system be made into a database but it has been a spreadsheet for so long that they do not feel they can change.
My thanks to you for your advice and suggestions. It has been fun trying to address the problem. Have a wonderful Christmas.
Reply With Quote
  #7  
Old 12-22-2017, 08:53 AM
ArviLaanemets ArviLaanemets is offline Error trapping Windows 8 Error trapping Office 2016
Expert
 
Join Date: May 2017
Posts: 932
ArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant futureArviLaanemets has a brilliant future
Default

Quote:
Originally Posted by Ricco49 View Post
it means setting up four extra columns to report the errors (one column for each check)
1. You can hide helper columns (and it will be better to place them at end of table).

2. Instead of helper columns you can use dynamical names. You select the row in table, create an new name, and set its source like the formula you used in helper column FOR THIS ROW. Now when you insert into some column for checking a formula = MyDynamicalName, for every row the name must return a value proper for this row. There is a caveat - Conditional Format doesn't understand anything about names. So you must have one helper column anyway, where you calculate a result value based on all names - then you can use the values in this column for your conditional format.

And Merry Christmas for you too!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error trapping Automation error Unknown error" message once they open the Excel file hlina Excel 1 10-08-2013 09:14 PM
Word Visual Basic error - run time error 504 crazymorton Word 11 01-13-2012 04:32 AM
Error trapping Microsoft office 2010 error 2908 and error 1935 !!!!!!heeeeellpppp!!!!!!!!! bennypryde Office 1 01-05-2012 03:33 PM
Runtime error 5487 - Word cannot complete the save to to file permission error franferns Word 0 11-25-2009 05:35 AM
Receive error cannot open this form because an error occurred in BCM 2007 bornhusker Outlook 0 06-01-2009 10:28 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:46 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft