Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Comparing 2 cells of a excel sheet data

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,62970
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Comparing 2 cells of a excel sheet data
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Comparing 2 cells of a excel sheet data - 7/30/2008 6:26:36 PM   
  ramgopalkota

 

Posts: 1
Score: 0
Joined: 7/30/2008
Status: offline
Original message moved by Admin
Reason :
Hi,

I have a excel sheet with a data from A3 to L41.I want to compare say A3 data to rest of the data and display which one matches with A3.
The cell to be searched will be selected by the user.
Can some body help me how to do it ? I am new to VB Scripting in Excel.

Please help !!!

 
 
Post #: 1
 
 RE: Comparing 2 cells of a excel sheet data - 8/4/2008 2:48:58 PM   
  ploosie

 

Posts: 45
Score: 0
Joined: 3/2/2008
Status: offline
Here is a compare script that I use all the time to compare 2 columns in Excel.  Just modify the script to suit your needs.

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Open("C:\YourExcelFile.xls")
Set objWorksheet = objWorkbook.Worksheets(1)
Set objRange = objWorksheet.Range("B1").EntireColumn
i = 1
Do Until objExcel.Cells(i, 1).Value = ""
  strName = objExcel.Cells(i, 1).Value
  Set objSearch = objRange.Find(strName)
  If objSearch Is Nothing Then
      Wscript.Echo strName & " MISSING!!"
Else Wscript.Echo strName & "Found"

 
  End If
  i = i + 1
Loop
Set objRange = objWorksheet.Range("A1").EntireColumn
i = 1
Do Until objExcel.Cells(i, 2).Value = ""
  strName = objExcel.Cells(i, 2).Value
  Set objSearch = objRange.Find(strName)
  If objSearch Is Nothing Then
      Wscript.Echo strName & " MISSING!!"
Else Wscript.Echo strName & "Found"


 
  End If
  i = i + 1
Loop

Msgbox "Done"

(in reply to ramgopalkota)
 
 
Revisions: 1 | Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Comparing 2 cells of a excel sheet data Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts