Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-06-2011, 05:11 AM
rajpeter rajpeter is offline vba code in excel Windows XP vba code in excel Office 2003
Novice
vba code in excel
 
Join Date: Sep 2011
Posts: 6
rajpeter is on a distinguished road
Default vba code in excel

hi
i need your help i have in sheet column 2
like Peter, RAJ


but i am comparing with other excel sheet 1 like RAJ,PETER
i am comparing sheet 2 against sheet1. here i am showing part of the code
how do i write
Code:
If Not IsEmpty(FullName) Then
intFullNameNum = InStr(1, FullName, ",")
If intEmpNameNum >= 1 Then 'Real Person's Name strEmpLNameChrUpper = UCase(Mid(EmpFullName, 1, 1))
strEmpFNameChrUpper = UCase(Mid(EmpFullName, intEmpNameNum + 1, 1))
strEmpLName = Trim(strEmpLNameChrUpper & LCase(Mid(strEmpFullName, 2, intEmpNameNum - 2)))
strEmpFName = Trim(strEmpFNameChrUpper & LCase(Mid(strEmpFullName, intEmpNameNum + 2)))
strEmployeeBothName = strEmpLName & ", " & strEmpFName
 
 
the above code shows PETER,RAJ
BUT IN SHEET 2 shows PETER, RAJ
 
Set M = Worksheets("Sheet2").Columns(2).Find(What:=x, MatchCase:=True)
THNAKS
Reply With Quote
  #2  
Old 09-06-2011, 09:20 AM
Catalin.B Catalin.B is offline vba code in excel Windows Vista vba code in excel Office 2007
Expert
 
Join Date: May 2011
Location: Iaşi, Romānia
Posts: 386
Catalin.B is on a distinguished road
Default

Quote:
the above code shows PETER,RAJ
BUT IN SHEET 2 shows PETER, RAJ
Code:
strEmployeeBothName = strEmpLName & ", "& strEmpFName
sorry, but the above code shows PETER, RAJ not PETER,RAJ as you say (look at the line 7 in your posted code)
at this row in your code, it says : put between the last name and first name a comma and a space... if you don't want a space between names, just delete the space after the comma...
and you can change in your code the lower case to upper case to match the format in the other sheet...
How do you want to use the results of this comparison?
(maybe if you upload a sample with data and desired results, will ease communication...)
Reply With Quote
  #3  
Old 09-06-2011, 09:44 AM
rajpeter rajpeter is offline vba code in excel Windows XP vba code in excel Office 2003
Novice
vba code in excel
 
Join Date: Sep 2011
Posts: 6
rajpeter is on a distinguished road
Default

HI
thanks for your reply i have sample sheet. different names last name and first name
some of them have - or . in middle
and first name
but all of them last name and first name are samein sheet 1 and sheet2.
but i need to have the same columns in each sheet if it has the same last name and first name.
Attached Files
File Type: xls Book2.xls (13.5 KB, 12 views)
Reply With Quote
  #4  
Old 09-06-2011, 10:39 PM
Catalin.B Catalin.B is offline vba code in excel Windows Vista vba code in excel Office 2007
Expert
 
Join Date: May 2011
Location: Iaşi, Romānia
Posts: 386
Catalin.B is on a distinguished road
Default

it's not an easy task, because there are too many variables in your names...
to be specific, first name in column A, sheet 1, PETER, RAJ, in sheet 2 is PETER, RAJ(DEV)
second entry sheet1: SUBBU PERIAY, RAM, in sheet 2: SUBBU-PERIAY, RAM
third entry: SEKAR, RAM in sheet 2: SEKAR, RAM(there are 2 spaces between names in sheet 2! )
If you say there could be an "." between names, all of this will mess up any code
only formulas that searches text within cell (not range...) will have some results (like : SEARCH("Peter";A1;1) or =IFERROR(IF(AND(SEARCH("Peter";A1;1);SEARCH("Raj"; A1;1))>0;1;0);0)
for this name, for example, PETER, RAJ(DEV) needs a formula to remove "(DEV)" from right name
My advice is , if possible, to assign an unique ID for people in your list...
searching after an ID is A LOT easier
Reply With Quote
  #5  
Old 09-11-2011, 06:11 PM
rajpeter rajpeter is offline vba code in excel Windows XP vba code in excel Office 2003
Novice
vba code in excel
 
Join Date: Sep 2011
Posts: 6
rajpeter is on a distinguished road
Default vba code

thanks
but where can i use this code . still confusing. please help me
thanks
Reply With Quote
  #6  
Old 09-11-2011, 06:13 PM
rajpeter rajpeter is offline vba code in excel Windows XP vba code in excel Office 2003
Novice
vba code in excel
 
Join Date: Sep 2011
Posts: 6
rajpeter is on a distinguished road
Default

when we have more than 1000 names how do we use unique id. compareing the names last name and first name
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Code in Project to Wake Up/Open Excel OTPM Excel Programming 2 05-23-2011 02:24 PM
vba code in excel Any tutorial same as to this excel sheet with code? Learner7 Excel 1 05-18-2010 05:31 PM
vba code in excel VB Code in Excel Active worksheet shakilhyd Excel 2 05-17-2010 07:50 AM
Excel ->VB code for Checkbox (control toolbox) kirkstyle Excel 0 08-16-2006 04:17 PM
Delete excel files by code in Access Barry Richardson Office 0 06-13-2005 06:26 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:31 AM.


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