Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Text comparison issue in macro...help!!!


I wrote a macro to compare two columns of alphanumeric codes with a list
of alphamnumeric codes on another tab in the same workbook. Basically,
I want to identify codes that do not appear in the list. Here is my
code:

Sub MacroCodes()
Dim i As Long
Dim j As Long
Dim k As Long
Dim Lrow As Long

ActiveSheet.Unprotect Password:="password"
Range("A1").Select
Selection.SpecialCells(xlCellTypeLastCell).Select
Lrow = ActiveCell.Row
Lcol = ActiveCell.Column
For i = 6 To Lrow
For j = 3 To 3
Application.Goto Cells(i, j)
If Not IsNumeric(ActiveCell.Value) = True Then
If ActiveCell.Value = Selection.FormulaArray =
"=OR(EXACT(ActiveCell.Value,DropDown))" = False Then
ActiveCell.Interior.ColorIndex = 6
End If
End If
Next j
Next i
For i = 6 To Lrow
For k = 6 To 6
Application.Goto Cells(i, k)
If Not IsNumeric(ActiveCell.Value) = True Then
If ActiveCell.Value = Selection.FormulaArray =
"=OR(EXACT(ActiveCell.Value,DropDown))" = False Then
ActiveCell.Interior.ColorIndex = 6
End If
End If
Next k
Next i
ActiveSheet.Protect Password:="password", DrawingObjects:=True,
Contents:=True, Scenarios:=True _
, AllowInsertingRows:=True, AllowDeletingRows:=True,
AllowSorting:=True
Range("A1").Select
End Sub

Right now, this macro colors all entries in the two scanned columns
yellow, whether it is in the list or not. I don't think the macro
likes the array formula I am trying to use. "DropDown" is a named
range I manually entered into my workbook. Is there another way to say
"look at the active cell and find its EXACT match in the named range"?


Thanks for any advice you all offer!!! (also, if there is a more
efficient way to write this, please don't hesitate to let me know!!!!).


--
Celt
------------------------------------------------------------------------
Celt's Profile: http://www.excelforum.com/member.php...o&userid=19413
View this thread: http://www.excelforum.com/showthread...hreadid=522022

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Text comparison issue in macro...help!!!

If Evaluate("OR(EXACT(" & ActiveCell.Value & ",DropDown))") Then

--
Regards,
Tom Ogilvy




"Celt" wrote in message
...

I wrote a macro to compare two columns of alphanumeric codes with a list
of alphamnumeric codes on another tab in the same workbook. Basically,
I want to identify codes that do not appear in the list. Here is my
code:

Sub MacroCodes()
Dim i As Long
Dim j As Long
Dim k As Long
Dim Lrow As Long

ActiveSheet.Unprotect Password:="password"
Range("A1").Select
Selection.SpecialCells(xlCellTypeLastCell).Select
Lrow = ActiveCell.Row
Lcol = ActiveCell.Column
For i = 6 To Lrow
For j = 3 To 3
Application.Goto Cells(i, j)
If Not IsNumeric(ActiveCell.Value) = True Then
If ActiveCell.Value = Selection.FormulaArray =
"=OR(EXACT(ActiveCell.Value,DropDown))" = False Then
ActiveCell.Interior.ColorIndex = 6
End If
End If
Next j
Next i
For i = 6 To Lrow
For k = 6 To 6
Application.Goto Cells(i, k)
If Not IsNumeric(ActiveCell.Value) = True Then
If ActiveCell.Value = Selection.FormulaArray =
"=OR(EXACT(ActiveCell.Value,DropDown))" = False Then
ActiveCell.Interior.ColorIndex = 6
End If
End If
Next k
Next i
ActiveSheet.Protect Password:="password", DrawingObjects:=True,
Contents:=True, Scenarios:=True _
, AllowInsertingRows:=True, AllowDeletingRows:=True,
AllowSorting:=True
Range("A1").Select
End Sub

Right now, this macro colors all entries in the two scanned columns
yellow, whether it is in the list or not. I don't think the macro
likes the array formula I am trying to use. "DropDown" is a named
range I manually entered into my workbook. Is there another way to say
"look at the active cell and find its EXACT match in the named range"?


Thanks for any advice you all offer!!! (also, if there is a more
efficient way to write this, please don't hesitate to let me know!!!!).


--
Celt
------------------------------------------------------------------------
Celt's Profile:

http://www.excelforum.com/member.php...o&userid=19413
View this thread: http://www.excelforum.com/showthread...hreadid=522022



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Text comparison issue in macro...help!!!


Thanks for the quick response Tom!

I dropped that snippet in and got a "Runtime Error '13': type
mismatch" error.

I am not quite sure why I am getting this (I have only written a few
macros with tons of help from the mvps on this site and I am still
getting my arms around VB).

I changed my original line to this:

If ActiveCell.Value = Evaluate("OR(EXACT(" & ActiveCell.Value &
",DropDown))") = False Then

did I mess something up?


--
Celt
------------------------------------------------------------------------
Celt's Profile: http://www.excelforum.com/member.php...o&userid=19413
View this thread: http://www.excelforum.com/showthread...hreadid=522022

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
text fragment comparison ChrisM Excel Worksheet Functions 2 January 6th 10 11:42 PM
Text Comparison bilswi[_2_] Excel Programming 0 November 5th 04 10:08 PM
Text Comparison bilswi Excel Programming 1 November 5th 04 04:55 PM
Issue with Excel Macro. Unable to insert quotes before and after the text. Vamsi Excel Programming 2 July 9th 04 06:43 AM
text comparison skippy Excel Programming 0 May 4th 04 02:20 PM


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