Results 1 to 10 of 11

Thread: VBA Macro To Fill Missing Items In A Sequence Of Values Based On Criteria

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    Another option

    Code:
    Sub imptype()
    
        Dim c   As Range
        Dim a   As String
        
        Set c = Range("J1:J" & Range("J" & Rows.Count).End(xlUp).Row)
        a = c.Address
        
        c = Evaluate("=if(" & a & "=""aip"",""Implant Pass-through: Auto Invoice Pricing (AIP)"",""Implant Pass-through: PPR Tied to Invoice"")")
    
    End Sub
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  2. #2
    Forum Guru Rick Rothstein's Avatar
    Join Date
    Feb 2012
    Posts
    662
    Rep Power
    15
    Here are two more options... the first one is mostly to show yet another alternative, but I seriously doubt you will find a faster method than the second one.

    Code:
    ' Interesting alternative
    '
    Sub ImpType1()
      With Range("J1:J" & Cells(Rows.Count, "J").End(xlUp).Row)
        .Replace "AIP", "=AIP", xlWhole
        .SpecialCells(xlConstants).Clear
        .SpecialCells(xlBlanks).Value = "Implant Pass-through: PPR Tied to Invoice"
        .SpecialCells(xlFormulas).Value = "Implant Pass-through: Auto Invoice Pricing (AIP)"
      End With
    End Sub
    Code:
    ' Super fast method
    '
    Sub ImpType2()
      Dim X As Long, vArr As Variant
      vArr = Range("J1:J" & Cells(Rows.Count, "J").End(xlUp).Row)
      For X = 1 To UBound(vArr)
        If vArr(X, 1) = "AIP" Then
          vArr(X, 1) = "Implant Pass-through: Auto Invoice Pricing (AIP)"
        Else
          vArr(X, 1) = "Implant Pass-through: PPR Tied to Invoice"
        End If
      Next
      Range("J1:J" & Cells(Rows.Count, "J").End(xlUp).Row) = vArr
    End Sub

Similar Threads

  1. Replies: 1
    Last Post: 08-20-2013, 04:31 PM
  2. Replies: 4
    Last Post: 04-05-2013, 12:08 PM
  3. Sum values based on multiple criteria
    By Jorrg1 in forum Excel Help
    Replies: 8
    Last Post: 01-07-2013, 03:04 PM
  4. Macro to clear data based on color fill
    By Howardc in forum Excel Help
    Replies: 7
    Last Post: 12-03-2012, 09:25 AM
  5. Fetch multiple values based on criteria
    By Lucero in forum Excel Help
    Replies: 8
    Last Post: 04-07-2012, 12:35 PM

Posting Permissions

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