Results 1 to 10 of 10

Populate Hlookup formula through VBA

Threaded View

  1. #6
    Registered User
    Join Date
    04-14-2019
    Location
    Singapore
    MS-Off Ver
    Office 365
    Posts
    20

    Re: Populate Hlookup formula through VBA

    Hi Jindon,

    Your solution worked but a small issue still remains:

    Sorry that I could not explain it clearly but please see below code wherein I used cell property so that I can use my Variable in MyRng .

    Now the first problem is solved but the other problem is I want to use Variable tRng in formula (b2) as under but I could not concatenate the same and it is giving one or the other issue . Can you pls help. First commented formula is working fine but the non commented one is not working. The reason is b2 in formula is also dynamic. Hope you understand . Thanks


    Sub test1()
        Dim ws1 As String, myRng As String
        
        
        ws1 = "TestCases"
        colmncnt = ThisWorkbook.Sheets(ws1).Cells(3, Columns.Count).End(xlToLeft).Column
        
        With Sheets(ws1)
            myRng = .Range(.Cells(3, 5), .Cells(7, colmncnt)).Address 'Sheets(ws1).Range("e3:r7").Address
        End With
        
        '//USe Variable for
        NewRow =2
        tRng = Range("b" & NewRow).Address(False, True)
        Debug.Print tRng
        
        With Sheets("TCTemplate")
            With .Range("c2", .Range("b" & Rows.Count).End(xlUp)(1, 2))
    '            .Formula = "=iferror(hlookup(""*""&b2,'" & ws1 & "'!" & myRng & ",5,false),"""")"
                .Formula = "=iferror(hlookup(""*"" " & tRng & " ,'" & ws1 & "'!" & myRng & ",5,false),"""")"
            End With
        End With
    
    End Sub
    Attached Files Attached Files
    Last edited by saxena_mk; 10-11-2021 at 08:02 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 07-22-2020, 09:55 AM
  2. Looking for help with what I think is a HLOOKUP formula
    By jamesemaj89 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-18-2016, 05:15 AM
  3. [SOLVED] HLOOKUP Formula Help
    By dmcf123 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-21-2014, 09:52 AM
  4. HLOOKUP Help. HLOOKUP links to Drop down list problems
    By finalmike in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-02-2013, 07:08 PM
  5. Replies: 3
    Last Post: 03-13-2012, 03:16 PM
  6. HLOOKUP in HLOOKUP, Base Estimate Table in Excel
    By gqdallas in forum Excel General
    Replies: 20
    Last Post: 10-19-2009, 01:41 PM
  7. Replies: 2
    Last Post: 10-08-2009, 09:51 PM

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