LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default compare two cells

On Jan 2, 3:17*pm, JLGWhiz wrote:
Yep, missed that. *Thanks Rick.

If c.Value "" And c.Offset(0, 1).Value = "" Then
* * * *MsgBox "No Value in " & c.Offset(0, 1).Address
End If

"Rick Rothstein" wrote:
You are not testing c.Value meaning you will pop a message when both c and
the offset are empty which the OP didn't want to have happen (unless, of
course, there are no blank rows internal to the data).


--
Rick (MVP - Excel)


"JLGWhiz" wrote in message
...
This code will walk the populated cells of Column T and check the content
of
the adjacent cell in column U. *If there is no value in column U the
message
box will appear and display the address of the blank cell. *Put this in
the
standard code module1.


Sub Due()
*lr = ActiveSheet.Cells(Rows.Count, 20).End(xlUp).Row
*Set srcRng = ActiveSheet.Range("T2:T" & lr)
*For Each c In srcRng
* *If c.Offset(0, 1).Value = "" Then
* * * MsgBox "No Value in " & c.Offset(0, 1).Address
* *End If
*Next
End Sub


"SangelNet" wrote:


seeking help on how to compare cell in two columns and get a message
if one is empty.


i have column T and U and would like to get a message if cell t1 has
something and cell u1 has nothing. if cell in column t have nothing
just exit the sub. if T has something and u has something just exit
the sub. just message when t has something and u does not.


i tries looking up something and nothing fits that need.


tried to cook up my own, but does not work. here is what i got


Sub compare()


* * Dim T As Range 'column T
* * Dim U As Range 'column U
* * Dim c As Range


* * Set T = Range("T")
* * Set U = Range("U")


* * For Each c In T


* * * * If T.Cells.Value = "" Then 'If T is empty the leave
* * * * * * Exit Sub
* * * * Else


* * * * * * If T.Cells = 1 And U.Cells = 1 Then '1 as in something 0
as in nothing
* * * * * * Exit Sub
* * * * Else
* * * * * * If T.Cells = 1 And U.Cells = 0 Then '1 as in something 0
as in nothing
* * * * * * MsgBox ("my message here")
* * * * End If
* * * * * * End If
* * * * * * End If


* * * * Next c


* * End Sub


any help * ? tHNX


Thnx a lot to both . Worked Just Fine!!!
 
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
compare 2 column cells and return the adjacent columns cells data of the cell trebor57 Excel Worksheet Functions 1 February 1st 11 02:54 PM
Compare 1 cell to column of cells returning adjacent cells info? Mr. Fine Excel Worksheet Functions 1 April 15th 10 07:36 PM
How do I compare cells and if FALSE compare to next cell in EXCEL Cindie Excel Worksheet Functions 0 March 24th 06 05:29 PM
Compare two cells from reference cells Mike K Excel Worksheet Functions 2 November 26th 05 02:07 PM
Compare 2 cells in 2 worksheets, rewrite one of the cells dbomb Excel Programming 1 September 28th 04 09:16 AM


All times are GMT +1. The time now is 05:56 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"