Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
| Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old March 23rd, 2006, 01:31 PM
Authorized User
Join Date: Oct 2004
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Errant application.union behaviour

I am trying to get a multiple area range made from a line-by-line comparison with a reference value. I am using code including the union method, but for some reason the union does not gather the parts as the rows are found. It simply drops the old row out for the new one, and the row.count is never more than 1.

Thanks for any help!

Here's the code I hope someone can figure this out:

Function GetRange(LookVals As Range, LookRange As Range) As Range
    Dim C As Object
    Dim CL As Object
    Dim rngSeed As Range
    Set rngSeed = LookRange.Rows(1).EntireRow
    For Each C In LookRange
        For Each CL In LookVals
            If C = CL Then
                Set rngSeed = Application.Union(rngSeed, C.EntireRow)
                Exit For
            End If
    Set GetRange = LookRange.Rows(1).EntireRow
End Function

Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange Behaviour VeganMan BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 9 April 14th, 2008 11:16 AM
Strange behaviour with IE smolds BOOK: Beginning CSS: Cascading Style Sheets for Web Design ISBN: 978-0-7645-7642-3 2 October 15th, 2005 08:49 PM
Strange TextBox Behaviour Jim Rogers Pro VB.NET 2002/2003 0 September 12th, 2005 07:13 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.