Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
compare two cell values on different sheets
hi I am a newbie to excel vba programming so please forgive if this is
silly question. I have an excel spreadsheet with two worksheets sheet1 and sheet2. need to do an if statement that compares two cell values. The cells o both sheets will already be active/selected. Thanks for any hel -- Message posted from http://www.ExcelForum.com |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
compare two cell values on different sheets
Here's a couple of examples:
Sub test() If Worksheets("sheet1").Range("A1").Value = Worksheets("sheet2").Range("A1").Value Then MsgBox "same" Else MsgBox "different" End If End Sub Sub test2() Dim rng1 As Range, rng2 As Range Set rng1 = Worksheets("sheet1").Range("A1") Set rng2 = Worksheets("sheet2").Range("A1") If rng1.Value = rng2.Value Then MsgBox "same" Else MsgBox "different" End If End Sub -- Rob van Gelder - http://www.vangelder.co.nz/excel "sagarh " wrote in message ... hi I am a newbie to excel vba programming so please forgive if this is a silly question. I have an excel spreadsheet with two worksheets sheet1 and sheet2. I need to do an if statement that compares two cell values. The cells on both sheets will already be active/selected. Thanks for any help --- Message posted from http://www.ExcelForum.com/ |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
compare two cell values on different sheets
What if the current selected cell is not A1 - my two sheets have 400
rows each and I am moving down the rows and doing a compare -- Message posted from http://www.ExcelForum.com |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
compare two cell values on different sheets
Dim rng1 as Range, i as Long
Dim cell as Range With worksheet("Sheet1") set rng1 = .Range(.Cells(1,1),.Cells(1,1).End(xldown)) End With i = 0 for each cell in rng1 if cell.Value < worksheets("Sheet2") _ .Range("A1").Offset(i,0).Value Then ' do what - they don't match else ' do what - they match End if i = i + 1 Next -- Regards, Tom Ogilvy "sagarh " wrote in message ... What if the current selected cell is not A1 - my two sheets have 4000 rows each and I am moving down the rows and doing a compare. --- Message posted from http://www.ExcelForum.com/ |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Auto generate sheets by different values of a cell. | Excel Discussion (Misc queries) | |||
Compare Sheets values in two colums | Excel Worksheet Functions | |||
Compare cell values | Excel Worksheet Functions | |||
how do i compare 2 spread sheets if the content of a cell is avai. | Excel Worksheet Functions |