Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Comparing two arrays/ranges

Hi there guys!
I have two tables with data say:

Cancun Merida
Article1 50.00 40.00
Article2 60.00 70.00

And the other table:

Cancun Merida
Article1 500.00 4000.00
Article2 600.00 7000.00

i need to compare the data in both tables, and color code the first one,
because we have two different prices, and the second table "normally" is the
first one by 6 (50.00 * 6) , but because the rates change depending on
season and customer, sometimes this "by 6" rule does not apply. So i need to
chage the color in the cells where the rule is not valid.
What im triying here is:

Sub CompararValores()
'varible declarations
Dim selec1, selec2 As Object
Dim i, j, numrows, numcols As Integer
Set selec1 = Application.InputBox(prompt:="Selecciona el Rango 1",
Type:=8)
Set selec2 = Application.InputBox(prompt:="Selecciona el Rango 2",
Type:=8)
i = CInt(selec1.Rows.Count)
numrows = CInt(selec2.Rows.Count)
j = CInt(selec1.Columns.Count)
numcols = CInt(selec2.Columns.Count)
If (numrows = i) And (numcols = j) Then 'To see if the selections are or
the same size

'THE PROBLEM is in this piece of code because i dont know how to cycle
trough the values of a range
'and i can't compare cell to cell (i.e. A1 with D1)

For Each j In selec1.Columns 'Here is the problem
If CInt(j.Value) = CInt(selec2.Offset(1, j).Value) Then
'Change color of cells
End If
Next j
Else
MsgBox "Selecciona rangos del mismo tamaño", vbExclamation
End If
End Sub

I could of course use two FOR cycles to compare each cell in the first range
with each cell of the second range, of couse this is not as ellegant as the
solution i want.

Any help or pointer to a help page would be apreciated


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
Ranges and Arrays in Excel VBA a.riva@UCL Excel Worksheet Functions 15 October 27th 07 12:15 AM
comparing ranges/arrays asaylor Excel Worksheet Functions 7 June 13th 06 11:53 PM
Comparing 2 arrays [email protected] Excel Worksheet Functions 3 January 2nd 06 02:31 AM
Comparing Arrays TangentMemory Excel Discussion (Misc queries) 2 May 13th 05 05:06 PM
Comparing Arrays KL Excel Worksheet Functions 9 December 3rd 04 08:58 PM


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