+ Reply to Thread
Results 1 to 1 of 1

Conditional Vlookup

Hybrid View

pkaskaggs Conditional Vlookup 08-17-2010, 01:53 PM
  1. #1
    Registered User
    Join Date
    08-17-2010
    Location
    Houston, Texas
    MS-Off Ver
    Excel 2007
    Posts
    2

    Conditional Vlookup

    I am using a Vlookup on a template that I paste a large report into, then run my macro. My Vlookup data is on three separate sheets in the workbook. If there is a code "4356" in column "G" then column "H", "I", "J" are populated with CITY, STATE, and NAME from a particular store code.

    Dim LR As Long, LR2 As Long
    LR = Worksheets("Dealer City").Cells(Rows.Count, 1).End(xlUp).Row
    LR2 = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
    With Worksheets("Sheet1").Range("H2:H" & LR2)
      .FormulaR1C1 = "=IF(ISNA(VLOOKUP(RC7,'Dealer City'!R1C1:R" & LR & "C2,2,FALSE)),"""",VLOOKUP(RC7,'Dealer City'!R1C1:R" & LR & "C2,2,FALSE))"
    
    End With
    
    With LR = Worksheets("Dealer State").Cells(Rows.Count, 1).End(xlUp).Row
           LR2 = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
      End With
      With Worksheets("Sheet1").Range("I2:I" & LR2)
            .FormulaR1C1 = "=IF(ISNA(VLOOKUP(RC7,'Dealer State'!R1C1:R" & LR & "C2,2,FALSE)),"""",VLOOKUP(RC7,'Dealer State'!R1C1:R" & LR & "C2,2,FALSE))"
      End With
      
      With LR = Worksheets("Dealer Names").Cells(Rows.Count, 1).End(xlUp).Row
            LR2 = Worksheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row
      End With
      With Worksheets("Sheet1").Range("J2:J" & LR2)
            .FormulaR1C1 = "=IF(ISNA(VLOOKUP(RC7,'Dealer Names'!R1C1:R" & LR & "C2,2,FALSE)),"""",VLOOKUP(RC7,'Dealer Names'!R1C1:R" & LR & "C2,2,FALSE))"
       End With
    My problem is that now,is a new Column "D" that contains the same codes. I need my lookups to do the lookup for "G" which has higher priority, but if "G" is empty use column "D" to populate CITY,STATE, NAME
    Basically, If Column “G” exists then Lookup, else Lookup “D”
    HTML Code: 
    Thanks for any help in advance
    Last edited by pkaskaggs; 08-17-2010 at 03:04 PM. Reason: Clarifying Problem

+ Reply to Thread

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