Results 1 to 5 of 5

Vba to fill vlookup formula until the end of used row

Threaded View

  1. #1
    Registered User
    Join Date
    06-03-2016
    Location
    Malaysia
    MS-Off Ver
    2010
    Posts
    56

    Vba to fill vlookup formula until the end of used row

    i have tried to make a code to fill a column with vlookup formula but it doesn't fill until end of the used row. i am not very good in coding, hope any expert here can help to correct my code.
    The steps i am trying to do is:
    1) In "working file.xlsm" copy the raw data from another workbook "Raw.xls" into "Sheet1"
    2) fill in column H by vlookup formula from sheet "Mst"
    I placed my command button at sheet "Mst".

    Private Sub CommandButton1_Click()
    
    Dim OpenFileName As String
    Dim wb As Workbook
    OpenFileName = Application.GetOpenFilename("clients saved spreadsheet,*.xls;*.xlsx")
    If OpenFileName = "False" Then Exit Sub
    Set wb = Workbooks.Open(OpenFileName)
    
    wb.Sheets("Sheet1").UsedRange.Copy
    ThisWorkbook.Sheets("Sheet1").Range("A1").PasteSpecial
    ThisWorkbook.Sheets("Sheet1").Range("H2:H" & Cells(Rows.Count, "A").End(xlUp).Row).Formula = "=VLOOKUP($C2,Mst!$A$1:$D$2000,4,0)"
    
    wb.Application.CutCopyMode = False
    wb.Close SaveChanges:=False
    
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] fill down vlookup formula difficulties
    By scross in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-15-2018, 06:22 PM
  2. [SOLVED] Use variable in Vlookup and then fill down formula in filtered worksheet
    By rn_ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-15-2016, 03:18 PM
  3. [SOLVED] How fill vlookup formula
    By Brett1966 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 10-01-2015, 06:11 AM
  4. Help with Vlookup formula or Other similar to fill data automaticly
    By fleyd in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 07-15-2015, 11:09 AM
  5. How do I fill in an entire table with a vlookup type formula?
    By PTS_1234 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 01-25-2013, 07:11 PM
  6. [SOLVED] fill column with vlookup formula to other workbook that depends on cell value
    By knick12 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-23-2012, 03:11 AM
  7. Auto fill down of vlookup formula
    By mikear82 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-08-2009, 11:11 AM

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