Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Code to compare

Is there code that would perform a compare btween two columns and should the
values not be the same then a yes/no message box can appear to alert the
user?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Code to compare

On Apr 1, 5:45 pm, acss wrote:
Is there code that would perform a compare btween two columns and should the
values not be the same then a yes/no message box can appear to alert the
user?


Yes there is. It would likely look something like this...

Private Sub CompareColumns()

Dim iCounter as Integer
Dim bnSame as Boolean

Do For iCounter = 1 to 150 'this gets changed depending on how many
rows you want to compare
If Cells(iCounter,1).Value = Cells(iCounter,2).Value Then
'if any value in column A = in column B
bnSame = True
iCounter = 150 'don't keep checking
End If
Loop

If bnSame = True Then
Msgbox "At least one identical value"
End If

End Sub

Throw that into a new module once you are in the VBE (Ctrl+F11) ...
post back with any more questions!

HTH

Chris
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Code to compare

Maybe if you could give me some more info. And what your data looks like in
the spreedsheet. I could cook you up something


"acss" wrote:

Is there code that would perform a compare btween two columns and should the
values not be the same then a yes/no message box can appear to alert the
user?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Code to compare

It is really something simple like if user typed in column A the amount of
100 then Column b should automatically have that value and should it not
then a message box would appear or some sort of error flag.

"Mike" wrote:

Maybe if you could give me some more info. And what your data looks like in
the spreedsheet. I could cook you up something


"acss" wrote:

Is there code that would perform a compare btween two columns and should the
values not be the same then a yes/no message box can appear to alert the
user?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Code to compare

Sub somethingSimple()
Const whatColumn = "A" 'Change to your needs
Dim looper As Long 'looper = 5 Starting row of data
Dim lastToCheckRow As Long
Dim cellPointer As Variant

lastToCheckRow = Range(whatColumn & Rows.Count).End(xlUp).Row

For looper = 1 To lastToCheckRow
Set cellPointer = Worksheets("Sheet1").Cells(looper, 1)
If cellPointer < cellPointer.Offset(0, 1) Then
MsgBox "Range(" & cellPointer.Address & ")" _
& " does not match Range(" & _
cellPointer.Offset(0, 1).Address & ")"
End If
Next looper
End Sub

"acss" wrote:

It is really something simple like if user typed in column A the amount of
100 then Column b should automatically have that value and should it not
then a message box would appear or some sort of error flag.

"Mike" wrote:

Maybe if you could give me some more info. And what your data looks like in
the spreedsheet. I could cook you up something


"acss" wrote:

Is there code that would perform a compare btween two columns and should the
values not be the same then a yes/no message box can appear to alert the
user?

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
VB code required to compare name list Anthony Excel Programming 7 February 6th 07 01:50 PM
Any way to compare VBA code in different workbooks? Cheer-Phil-ly Excel Programming 4 January 6th 07 02:45 AM
Problem with code. (Compare all cells) Metrazal[_46_] Excel Programming 1 March 10th 06 07:34 PM
Help with VB code to compare two columns Farooq Sheri Excel Programming 3 January 23rd 06 11:10 AM
Compare tabs using Double Lookup, in VB code Ricky Pang Excel Programming 4 October 29th 03 06:50 PM


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

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

About Us

"It's about Microsoft Excel"