Results 1 to 4 of 4

Help to Compare with 4 variables

Threaded View

  1. #1
    Registered User
    Join Date
    12-03-2012
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2007
    Posts
    16

    Help to Compare with 4 variables

    Hi there

    I'm trying to make a seach function based on compare.
    It' just does'nt work.
    Is it because compare doesn't support multible variables.
    If yes, what should I use insted?
    This is what I've made

    Sub Test()
    
    
        Dim CompareRange As Variant, A As Variant, B As Variant, X As Variant, Y As Variant
    
    
         Sheets("123").Select
         Range("B2:Z2").Select and Range("A3:A10")
          ' ("B2:Z2") is selection A
          ' ("A3:A10") is selction X
         
    
        Set CompareRange = Workbooks("ABC").Worksheets("456").Range("B3:B260") and Range("C3:C260")
          ' ("B3:B260") is CompareRange B
          ' ("C3:C260") is CompareRange Y
    
        For Each A In Selection
            For Each B In CompareRange
    
        For Each X in selction
            For Each Y in CompareRange
    
    
                If A = B And B <> 0 And X = Y and Y <> 0 Then X.Offset(0, 1) = B.Offset(0, -1)
    
            Next B
         Next A
            Next Y
         Next X
    End Sub
    Thanks to aelgadi
    Last edited by Blichfeldt; 12-03-2012 at 10:59 AM. Reason: Make the code easier to read

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1