+ Reply to Thread
Results 1 to 6 of 6

Vlookup with dynamic range selection using Inputbox

Hybrid View

  1. #1
    Registered User
    Join Date
    12-24-2012
    Location
    Bangalore
    MS-Off Ver
    Excel 2007
    Posts
    99

    Vlookup with dynamic range selection using Inputbox

    Can anyone help me to perform Vlookup functionality by accepting the range using inputbox. For example, i have 2 columns column A and Column B as mentioned below:

    Column A Column B

    1 4
    2 5
    3 1
    4 3
    5 10
    6 9

    I want to select the range via inputbox and vlookup the values in Column B with values in Column A or vice versa and find out the difference. Or is there any better way to achieve the same? The following is a simple macro generated with Range hardcoded.

    Sub Vlookup_func()
        Range("C2").Select
        ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],R2C[-2]:R6C[-2],1,FALSE)"
        Range("C2").Select
        Selection.AutoFill Destination:=Range("C2:C6")
        Range("C2:C6").Select
        End Sub

  2. #2
    Registered User
    Join Date
    12-24-2012
    Location
    Bangalore
    MS-Off Ver
    Excel 2007
    Posts
    99

    Re: Vlookup with dynamic range selection using Inputbox

    Can someone help me with the above requirement?

  3. #3
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Vlookup with dynamic range selection using Inputbox

    Hi Pavan Renjal,
    Look at the last post in this thread. Maybe you'll find something suitable for you

  4. #4
    Registered User
    Join Date
    12-24-2012
    Location
    Bangalore
    MS-Off Ver
    Excel 2007
    Posts
    99

    Re: Vlookup with dynamic range selection using Inputbox

    Hi Nilem,

    Can you help me explain this? I am relatively new to macro here. I did a walkthrough but i didnt find anything for me there, i want to use Vlookup functionality.

  5. #5
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Vlookup with dynamic range selection using Inputbox

    Or

    Try like this...

    Sub Vlookup_func()
    Dim rMyRng As Range, rLkpCell As Range, rRes As Range, iCl As Integer, blType As Boolean
    
    Set rLkpCell = Application.InputBox("Select The Lookup Cell", "Lookup Cell Req", , , , , , 8)
    Set rMyRng = Application.InputBox("Select The Vlookup Range", "Vlookup Range Req", , , , , , 8)
    iCl = InputBox("Enter the Output Column No", "Result Column # Req")
    blType = InputBox("Enter Match Type", "True/False Req", False)
    Set rRes = Application.InputBox("Select Result Range", "Result Range Req", , , , , , 8)
    
    rRes.Formula = "=VLookup(" & rLkpCell.Address(0, 0) & "," & rMyRng.Address & _
                    "," & iCl & "," & blType & ")"
    End Sub


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  6. #6
    Registered User
    Join Date
    12-24-2012
    Location
    Bangalore
    MS-Off Ver
    Excel 2007
    Posts
    99

    Re: Vlookup with dynamic range selection using Inputbox

    Bulls Eye! Thanks for all your time and effort Sixth Sense!!

+ Reply to Thread

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