Results 1 to 4 of 4

IF, Then AND - problems with Syntax

Threaded View

  1. #1
    Registered User
    Join Date
    01-05-2012
    Location
    Salinas
    MS-Off Ver
    Excel 2007
    Posts
    22

    IF, Then AND - problems with Syntax

    Having some problems with Syntax. I have some experience with programming macros, but this doesn't seem to be working... what am I doing wrong? My goal is to compare 4 separate cell pairs in two different worksheets - if the 4 cell pairs are equivalent then one of the worksheets will be populated by another. Here is what I have. Any help would be greatly appreciated:

    For k = 1 To x_last_row
        
        For i = 1 To y_last_row
         
      If
      
      Worksheets("X").Cells(k, 4).Value = Worksheets("Y").Cells(i, 2).Value And
      Worksheets("X").Cells(k, 11).Value = Worksheets("Y").Cells(i, 3).Value And
      Worksheets("X").Cells(k, 13).Value = Worksheets("Y").Cells(i, 4).Value And
      Worksheets("X").Cells(k, 7).Value = Worksheets("Y").Cells(i, 5).Value
        
      THEN
        
        Worksheets("Y").Cells(i, 87) = Worksheets("X").Cells(k, 1)
        Worksheets("Y").Cells(i, 88) = Worksheets("X").Cells(k, 2)
        Worksheets("Y").Cells(i, 89) = Worksheets("X").Cells(k, 3)
        Worksheets("Y").Cells(i, 90) = Worksheets("X").Cells(k, 4)
        Worksheets("Y").Cells(i, 91) = Worksheets("X").Cells(k, 5)
        
        
        End If
    
        Next i
    
    Next k
    Last edited by Cutter; 09-21-2012 at 09:33 PM. Reason: Added code tags

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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