Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Comparing three columns in 2 sheets

I have a spreadsheet with two sheets named 'RQ' and 'HL'.

I have three columns called 'user name', 'record number'
and 'date' in both sheets.

I need to check whether each row (based on the data in the
three columns) in 'HL' is in the sheet 'RQ' and if it is
not, then colour the row is 'HL'.

The data in 'HL' is dynamic, so the ammount of rows vary.

Example

'HL'

c12345 555 13/01/04
c54321 123 13/01/04
c67890 7458 13/01/04

'RQ'

c12345 555 13/01/04
c67890 7458 13/01/04

Result

The second row in 'HL' would be coloured.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Comparing three columns in 2 sheets

Simon,

Sub testit()
Dim wksS As Worksheet, wksD As Worksheet
Dim i As Long, j As Long, lngLastRowS As Long, lngLastRowD As Long
Dim blnFound As Boolean

Set wksS = Worksheets("HL")
Set wksD = Worksheets("RQ")

lngLastRowS = wksS.Cells(Rows.Count, 1).End(xlUp).Row
lngLastRowD = wksD.Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lngLastRowS
blnFound = False
For j = 1 To lngLastRowD
If wksS.Cells(i, 1) = wksD.Cells(j, 1) And wksS.Cells(i, 2) =
wksD.Cells(j, 2) Then
blnFound = True
Exit For
End If
Next
If Not blnFound Then wksS.Rows(i).Interior.ColorIndex = 35
Next
End Sub

Rob


"Simon" wrote in message
...
I have a spreadsheet with two sheets named 'RQ' and 'HL'.

I have three columns called 'user name', 'record number'
and 'date' in both sheets.

I need to check whether each row (based on the data in the
three columns) in 'HL' is in the sheet 'RQ' and if it is
not, then colour the row is 'HL'.

The data in 'HL' is dynamic, so the ammount of rows vary.

Example

'HL'

c12345 555 13/01/04
c54321 123 13/01/04
c67890 7458 13/01/04

'RQ'

c12345 555 13/01/04
c67890 7458 13/01/04

Result

The second row in 'HL' would be coloured.




  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Comparing three columns in 2 sheets

Thanks you,

This worked great.

Simon
-----Original Message-----
Simon,

Sub testit()
Dim wksS As Worksheet, wksD As Worksheet
Dim i As Long, j As Long, lngLastRowS As Long,

lngLastRowD As Long
Dim blnFound As Boolean

Set wksS = Worksheets("HL")
Set wksD = Worksheets("RQ")

lngLastRowS = wksS.Cells(Rows.Count, 1).End(xlUp).Row
lngLastRowD = wksD.Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lngLastRowS
blnFound = False
For j = 1 To lngLastRowD
If wksS.Cells(i, 1) = wksD.Cells(j, 1) And

wksS.Cells(i, 2) =
wksD.Cells(j, 2) Then
blnFound = True
Exit For
End If
Next
If Not blnFound Then wksS.Rows

(i).Interior.ColorIndex = 35
Next
End Sub

Rob


"Simon" wrote in

message
...
I have a spreadsheet with two sheets named 'RQ'

and 'HL'.

I have three columns called 'user name', 'record number'
and 'date' in both sheets.

I need to check whether each row (based on the data in

the
three columns) in 'HL' is in the sheet 'RQ' and if it is
not, then colour the row is 'HL'.

The data in 'HL' is dynamic, so the ammount of rows

vary.

Example

'HL'

c12345 555 13/01/04
c54321 123 13/01/04
c67890 7458 13/01/04

'RQ'

c12345 555 13/01/04
c67890 7458 13/01/04

Result

The second row in 'HL' would be coloured.




.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default Comparing three columns in 2 sheets

Simon,

Small typo.
It should have read: If wksS.Cells(i, 1) = wksD.Cells(j, 1) And
wksS.Cells(i, 2) = wksD.Cells(j, 2) And wksS.Cells(i, 3) = wksD.Cells(j, 3)
Then

Rob


wrote in message
...
Thanks you,

This worked great.

Simon
-----Original Message-----
Simon,

Sub testit()
Dim wksS As Worksheet, wksD As Worksheet
Dim i As Long, j As Long, lngLastRowS As Long,

lngLastRowD As Long
Dim blnFound As Boolean

Set wksS = Worksheets("HL")
Set wksD = Worksheets("RQ")

lngLastRowS = wksS.Cells(Rows.Count, 1).End(xlUp).Row
lngLastRowD = wksD.Cells(Rows.Count, 1).End(xlUp).Row
For i = 1 To lngLastRowS
blnFound = False
For j = 1 To lngLastRowD
If wksS.Cells(i, 1) = wksD.Cells(j, 1) And

wksS.Cells(i, 2) =
wksD.Cells(j, 2) Then
blnFound = True
Exit For
End If
Next
If Not blnFound Then wksS.Rows

(i).Interior.ColorIndex = 35
Next
End Sub

Rob


"Simon" wrote in

message
...
I have a spreadsheet with two sheets named 'RQ'

and 'HL'.

I have three columns called 'user name', 'record number'
and 'date' in both sheets.

I need to check whether each row (based on the data in

the
three columns) in 'HL' is in the sheet 'RQ' and if it is
not, then colour the row is 'HL'.

The data in 'HL' is dynamic, so the ammount of rows

vary.

Example

'HL'

c12345 555 13/01/04
c54321 123 13/01/04
c67890 7458 13/01/04

'RQ'

c12345 555 13/01/04
c67890 7458 13/01/04

Result

The second row in 'HL' would be coloured.




.



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
Comparing Across Sheets RJB Excel Discussion (Misc queries) 1 March 6th 08 02:23 AM
Comparing columns in sheets jpreman Excel Discussion (Misc queries) 6 July 11th 07 03:46 AM
Comparing multiple columns in two sheets [email protected] Excel Worksheet Functions 1 March 30th 07 07:12 PM
Comparing columns iin 2 sheets to generate one CCTD via OfficeKB.com Excel Worksheet Functions 0 September 26th 05 08:34 PM
comparing 2 similar columns on seperate work sheets in 1 workbook Dan Excel Discussion (Misc queries) 4 September 20th 05 11:58 PM


All times are GMT +1. The time now is 01:35 AM.

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"