View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Comparing Cell values in two sheets within the same workbook

I sthe data in the same format? If it is strings then use strcomp.

when I havve this problem I add extra code to debug the problem
I added a & b before the if staement. Put a break point (F9) at the If
statement and check the values of a & b. this should find the problem. You
also may need to add the .value to the If statement.

a = ActikveCell.value
b = Sheets("mis tool").ActiveCell.value

If ActiveCell = Sheets("mis tool").ActiveCell Then


" wrote:

This is the code i have.

i want to compare a range of values in column H in sheet 1 with a
column that is in the sheet called 'mis tool'

I have the code looping down the range in sheet 1 and comparing to the
1st value in sheet 'mis tool', once the range in sheet 1 has run
throught, the cell selected in 'mis tool' will move down 1 and then it
will re-check for similar values.

the problem i have is that i can't get the code to pick up on entries
that are equal to each other.

I need an if statement that can compare the selected cell in sheet 1
with the selected cell in sheet 'mis tool', all cells are numerical
entries

the code as it is stops at the first IF statement, but otherwise does
what i need it to do.

any ideas?

Sub Macro1()

Sheets("Sheet1").Select
Range("H2").Select
Sheets("mis tool").Select
Range("F2").Select
Sheets("Sheet1").Select
Do
Do While ActiveCell < 0
If ActiveCell = Sheets("mis tool").ActiveCell Then
Sheets("mis tool").Select
ActiveCell.Offset(0, 3).Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Sheet1").Select
ActiveCell.Offset(0, 13).Select
ActiveSheet.Paste
ElseIf ActiveCell < Sheets("mis tool").ActiveCell Then
Sheets("Sheet1").Select
ActiveCell.Offset(1, 0).Select
End If
Loop
If ActiveCell = 0 Then
Sheets("Sheet1").Select
Range("H2").Select
Sheets("mis tool").Select
ActiveCell.Offset(1, 0).Select
End If
Loop Until ActiveCell = 0
End Sub