PC Review


Reply
Thread Tools Rate Thread

Application.Match and Ranges

 
 
gimme_this_gimme_that@yahoo.com
Guest
Posts: n/a
 
      4th Nov 2006
I'd like to get the following clip of code to work:

I fathom that Excel is bulking because it can't use a compare a range
against a range?

Any suggestions?

Thanks.


Set ws = book.Sheets("WorkAResultSet")
Set wr = ws.Range("A1", "B" + Format(Utils.RowCount(ws)))
For itr = 1 To 3
t.Cells(1, itr + 8).Value = UCase(ws.Cells(1, itr).Value)
Next itr
For itr = 2 To nw
res = Application.Match(t.Range(t.Cells(itr, 1), t.Cells(itr, 2)),
wr, 0)
For j = 1 To 5
t.Cells(itr, j + 8).Value = ws.Cells(res, j).Value
Next j
Next itr

 
Reply With Quote
 
 
 
 
Peter T
Guest
Posts: n/a
 
      4th Nov 2006
This worked for me

Sub test()
Dim rngArray As Range, rngValue As Range
Dim vRes As Variant

Set rngArray = Range("a1:a10")
Set rngValue = Range("c5")

vRes = Application.Match(rngValue, rngArray, 0)
If VarType(vRes) = vbError Then
MsgBox "no match"
Else
MsgBox vRes
End If

End Sub

Not possible to second guess what your variables refer to and why your code
fails

Regards,
Peter T


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'd like to get the following clip of code to work:
>
> I fathom that Excel is bulking because it can't use a compare a range
> against a range?
>
> Any suggestions?
>
> Thanks.
>
>
> Set ws = book.Sheets("WorkAResultSet")
> Set wr = ws.Range("A1", "B" + Format(Utils.RowCount(ws)))
> For itr = 1 To 3
> t.Cells(1, itr + 8).Value = UCase(ws.Cells(1, itr).Value)
> Next itr
> For itr = 2 To nw
> res = Application.Match(t.Range(t.Cells(itr, 1), t.Cells(itr, 2)),
> wr, 0)
> For j = 1 To 5
> t.Cells(itr, j + 8).Value = ws.Cells(res, j).Value
> Next j
> Next itr
>



 
Reply With Quote
 
gimme_this_gimme_that@yahoo.com
Guest
Posts: n/a
 
      6th Nov 2006
Thanks Peter,

I think you example works because mgValue is a single cell.
>
> Not possible to second guess what your variables refer to and why your code
> fails
>
> Regards,
> Peter T
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding a column if two ranges match xRai Microsoft Excel Misc 4 13th Mar 2010 02:46 AM
Match Ranges problem , ytayta555 Microsoft Excel Programming 13 3rd Mar 2010 11:46 AM
Application.Match - Is it possible to use named ranges? Mike G - DC Microsoft Excel Programming 5 10th Jul 2009 04:41 PM
Like match between 2 ranges dean@spiralsolutions.com Microsoft Excel Misc 3 21st Jul 2005 05:40 AM
VLOOKUP/MATCH with Ranges Rudy Microsoft Excel Worksheet Functions 1 2nd Jul 2003 10:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:39 PM.