Results 1 to 7 of 7

VBA to execute when target cell value changed/filled

Threaded View

  1. #1
    Registered User
    Join Date
    08-18-2012
    Location
    Singapore
    MS-Off Ver
    Excel 2010
    Posts
    41

    Question VBA to execute when target cell value changed/filled

    Hi all,

    I have a VBA when it will execute after a hotkey is pressed. Basically to vlookup the value present on cell B onto C, D, E, etc.

    If I want to modify it such that it will detect that there is value in cell B2, and automatically execute the vlookup in C2, D2, E2, etc.

    Right now, if any of the cell in B is changed, will need to press the hotkey for them to re-calculate.

    Attached is the excel screenshot.

    Any help will be appreciated, thanks a lot.

    2013-03-03 23_43_01-Microsoft Excel - Label Issue - RTS List - Supplier Info.png

    Sub Macro5()
    '
    ' Macro5 Macro
    '
    ' Keyboard Shortcut: Ctrl+Shift+H
    '
        Range("C2").Select
        ActiveCell.FormulaR1C1 = "=VLOOKUP(LEFT(RC[-1],5),'DIR - L'!C:C[4],5,FALSE)"
        Range("D2").Select
        ActiveCell.FormulaR1C1 = _
            "=VLOOKUP(LEFT(RC[-2],12),'DIR - L'!C[-2]:C[4],7,FALSE)"
        Range("E2").Select
        ActiveCell.FormulaR1C1 = _
            "=VLOOKUP(LEFT(RC[-3],12),'DIR - L'!C[-3]:C[6],10,FALSE)"
        Range("F2").Select
        ActiveCell.FormulaR1C1 = _
            "=VLOOKUP(LEFT(RC[-4],12),'DIR - L'!C[-4]:C[9],14,FALSE)"
        Range("G2").Select
        ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-5],'DIR - L'!C[-6]:C[-1],6,FALSE)"
        Range("H2").Select
        ActiveCell.FormulaR1C1 = "=RC[-3]&"" - ""&RC[-2]"
        Range("H3").Select
        Columns("H:H").EntireColumn.AutoFit
        Range("C2:H2").Select
        Selection.AutoFill Destination:=Range("C2:H" & Range("B" & Rows.Count).End(xlUp).Row)
        Range("C2:H" & Range("B" & Rows.Count).End(xlUp).Row).Select
    End Sub
    Last edited by arlu1201; 03-03-2013 at 02:31 PM. Reason: Code tags and not quote tags.

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