![]() |
#1
|
|||
|
|||
![]()
Hello all,
Thank you for stopping by. I have a spreadsheet with many rows. Each row has an ID made up of numbers and letters. For some reason, when I exported the data from our database some records were duplicated. However, the duplicated records have the letters in the ID lowercase. I need to remove the duplicate rows that have the ID letters lowercase and I need to keep the ID's with uppercase letters. Is there a formula or VBA that will do this for me? Example 1: 123RT456 - (keep) 123rt456 - (remove) Example 2: 9123847JH2351234H - (keep) 9123847jh2351234h - (remove) I really appreciate your help! Rey |
#2
|
||||
|
||||
![]()
Hi Rey,
When doing the VBA comparison, wrap both expressions in the UCase function. This will force the comparison to be done on the basis of the capitalized versions of the strings. Code:
Sub Demo() With ActiveSheet If UCase(.Range("A1").Value) = UCase(.Range("B1").Value) Then MsgBox "!" End If End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] Last edited by macropod; 05-03-2011 at 01:23 AM. |
#3
|
|||
|
|||
![]()
Thanks Macropod for your reply!
I'm not sure what you mean by wrapping both expressions. Can you help me out with that with an example? Also, when applying this VBA code, will a message pop up for each match that is found? That wouldn't be the best option because there's hundreds of rows where the ID's match. Is it possible to write some text in the next column with the words "Match" or something like that? Thanks again! Rey |
#4
|
||||
|
||||
![]() Quote:
Quote:
Yes, but (again) that depends on your code.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
![]() Quote:
Quote:
Quote:
|
#6
|
||||
|
||||
![]() Quote:
If UCase(.Range("A1").Value) = UCase(.Range("B1").Value) Then In this example, the Ucase function encompasses the other expression on each side of the '=' symbol. Quote:
What you're asking can't be done via formulae, since formulae can't delete rows. So, unless you want to use Excel's 'UPPER' worksheet function to compare the values in your ranges, then manually delete the duplicate rows, you'll need vba. And, before anyone can provide a vba solution, you'll need to supply details of the ranges to be compared and, where a match is found, which of those ranges is to be deleted and which is to be flagged.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
![]()
At this point, I don't need to remove rows. I just want Excel to flag which rows have the ID numbers in lowercase letters.
I can manually remove them after they're flagged. Is your example the best and/or easiest way to do this? |
#8
|
|||
|
|||
![]()
I just found exactly what I was looking for. Here's the formula:
=IF(EXACT(B4,LOWER(B4)),"Lower Case","") All I needed to know was which ID's in Column B where lower case. Thanks for your efforts! |
#9
|
||||
|
||||
![]()
Hi Rey,
That will tell you which cells are in lower case, but not which lower-case cells are duplicates of upper-case cells: Quote:
=TRIM(IF(COUNTIF(B$1:B1,B1)> 1,"Duplicate","")&" "&IF(EXACT(B1,LOWER(B1)),"Lower Case","")) if you put the above formula in, say, D1 and copy it down as far as needed, it will report both duplicates (regardless of case) and lower-case forms (regardless of duplication).
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to determine a user's mailbox size limit? | enviroko | Outlook | 3 | 05-13-2010 07:02 AM |
Macro to determine attached template | zippyaus | Word VBA | 0 | 03-02-2010 02:05 AM |
Anyway to determine time/date of text creation? | pureride | Word | 1 | 01-05-2010 02:09 PM |
![]() |
gdodson | Excel | 1 | 08-11-2006 09:27 PM |