Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA - VLookup ?


Group,
Lets assume I have two worksheets within the same workbook. Let
also assume that I have approximately 30 Columns of data with 100 rows
The names in column 1 for the most part rarely changes. If they do
its because a row has either been added or deleted somewhere in th
respective spreadsheets. The names in Column 1 are always unique. S
comparing would be, find a name in Sheet 1 Column 1, next look for tha
same name in Sheet 2, Column 1. If there is a match, then compare eac
row for differences. If there is a change, alter the color of the cel
in both worksheets. If a row has been added and doesn't appear in bot
worksheets, highlight the row with the addition. If a row is delete
highlight the row in the previous worksheet not deleted. For a ver
compact comparison routine, would VLOOKUP be my choice to determin
changes? If not, what could satisfy my requirements?

Ton

--
ajociu
-----------------------------------------------------------------------
ajocius's Profile: http://www.excelforum.com/member.php...fo&userid=1769
View this thread: http://www.excelforum.com/showthread.php?threadid=39484

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default VBA - VLookup ?

Hi,
MATCH or VLOOKUP:

Sub MatchCol()


Dim rng1 As Range, rng2 As Range, res

With Worksheets("sheet1")
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set rng1 = .Range("a2:a" & Lastrow)
End With

With Worksheets("sheet2")
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row
Set rng2 = .Range("a2:a" & Lastrow)
End With

For Each cell In rng1

res = Application.VLookup(cell, rng2, 1, False) ' Lookup cell in Rng1 with
Rng2
'
' OR
'
res = Application.Match(cell, rng2, 0) ' Match cell in Rng1 with Rng2

If Not IsError(res) Then ' Matched i.e.
'
' Compare rows .....
'
Else

' Highlight row in Sheet1 i.e. it is missing in Sheet2
End If
Next cell
End Sub

"ajocius" wrote:


Group,
Lets assume I have two worksheets within the same workbook. Lets
also assume that I have approximately 30 Columns of data with 100 rows.
The names in column 1 for the most part rarely changes. If they do,
its because a row has either been added or deleted somewhere in the
respective spreadsheets. The names in Column 1 are always unique. So
comparing would be, find a name in Sheet 1 Column 1, next look for that
same name in Sheet 2, Column 1. If there is a match, then compare each
row for differences. If there is a change, alter the color of the cell
in both worksheets. If a row has been added and doesn't appear in both
worksheets, highlight the row with the addition. If a row is deleted
highlight the row in the previous worksheet not deleted. For a very
compact comparison routine, would VLOOKUP be my choice to determine
changes? If not, what could satisfy my requirements?

Tony


--
ajocius
------------------------------------------------------------------------
ajocius's Profile: http://www.excelforum.com/member.php...o&userid=17695
View this thread: http://www.excelforum.com/showthread...hreadid=394841


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
If (Vlookup 0) working, but what if Vlookup cell does not exist Steve Excel Worksheet Functions 18 November 18th 09 07:33 PM
Vlookup in vlookup - taking the result as array name SupperDuck Excel Worksheet Functions 2 June 2nd 07 11:05 AM
Combine VLOOKUP and IF function so #NA isn't returned as a value from VLOOKUP buffgirl71 Excel Discussion (Misc queries) 12 November 14th 06 11:36 PM
Vlookup -=VLOOKUP(F9,LookUp1!$A$2:$B$1504,2,FALSE) MikeR-Oz New Users to Excel 1 March 22nd 06 09:01 AM
Vlookup info being used without vlookup table attached? Excel Worksheet Functions 0 January 25th 05 10:43 AM


All times are GMT +1. The time now is 05:02 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"