+ Reply to Thread
Results 1 to 4 of 4

Need Help on VLookup Macro

  1. #1
    Registered User
    Join Date
    10-29-2014
    Location
    Okc
    MS-Off Ver
    Office 2013
    Posts
    9

    Need Help on VLookup Macro

    I am wanting to create a macro where it will do a vlookup on two different workbooks and past the values along with the formatting into a different spreadsheet. This is what I got:

    Source worksheet (drivercheck)
    Thursday (drop down box)
    Column A Column B
    Route Driver
    V01 John Bailey
    V02 Ralph
    V03 Sam
    etc

    Destination worksheet (recap)
    Column A Column B Column C
    Rt Load # Driver
    V01
    V02
    V03
    etc

    The macro will have to "live" in the source worksheet as the location of the destination worksheet is a different location everyday. The source worksheet already does a vlookup and does a conditional formatting to highlight the changes. The highlighted changes currently are manually copied over to the destination worksheet. I would like where the macro will take the highlighted changes and copy them over along with the highlighting to the destination worksheet. Therefore what I am looking for is to open both spreadsheets and run the macro to insert the changes into the destination worksheet.

    Thank you so much,
    Jeremy

  2. #2
    Registered User
    Join Date
    10-29-2014
    Location
    Okc
    MS-Off Ver
    Office 2013
    Posts
    9

    Re: Need Help on VLookup Macro

    This is the code I started with. It has some errors:

    Sub Macro1()
    Dim sourcelastrow As Long
    Dim outputlastrow As Long
    Dim sourcesheet As Worksheet
    Dim outputsheet As Worksheet

    'names of worksheets
    Set sourcesheet = daily_drivercheck_rev2.xlsx("daily_check")
    Set outputsheet = route_rec_recap_sheet_OKC - Tulsa.xlsx("route_check-in_sheet_okc")

    'determine last row of source
    With sourcesheet
    sourcelastrow = .Cells(.Rows.Count, "A").End(x1Up).Row
    End With
    With outputsheet
    'determine last row in col C
    outputlastrow = .Cells(.Rows.Count, "C").End(x1Up).Row
    'Apply our formula
    .Range("C1:C" & outputlastrow).Formula = _
    "=vlookup(A2, '" & sourcesheet.Name & "'!$A$2:$B$" & sourcelastrow & ",2,0)"
    End With


    ' Macro1 Macro
    '

    '
    End Sub

  3. #3
    Forum Contributor
    Join Date
    04-20-2015
    Location
    Switzerland
    MS-Off Ver
    2010
    Posts
    312

    Re: Need Help on VLookup Macro

    Would like to Help you but i don`t understand what exactly needs to be copied from A to B.
    Could you explain little bit more detailed what Data goes from Where to Where? Or post an Example of the to Sheets as they are now?

    Greets
    Loki

  4. #4
    Registered User
    Join Date
    10-29-2014
    Location
    Okc
    MS-Off Ver
    Office 2013
    Posts
    9

    Re: Need Help on VLookup Macro

    Hope this helps.Screen Shot 2015-04-23 at 8.07.44 AM.pngScreen Shot 2015-04-23 at 8.08.18 AM.png

    I hope the pictures do justice, however what is happening on worksheet A is it is pulling in "changes" from the defaults and do a conditional formatting to yellow. Currently we do a manual copy to the same route number, ie va1, va2, va3, etc., that is located on sheet B. Sheet B lives in a different folder everyday, so the coding will have to live in Sheet A.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 3
    Last Post: 07-10-2014, 10:56 AM
  2. [SOLVED] Adapt A Sumif Macro to A Vlookup Macro
    By timbo1957 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-30-2012, 06:22 PM
  3. Complex Vlookup/ VBA function or Macro Needed For "if contains text then vlookup"
    By alfykunable in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-09-2012, 03:48 AM
  4. Applying Vlookup using a Macro(Vlookup+Macro) in Excel 2007
    By Sumku in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-03-2009, 08:58 PM
  5. [SOLVED] 255 Character Truncation, Vlookup Macro vs. Opening Workbook Macro
    By jrew23@yahoo.com in forum Excel General
    Replies: 1
    Last Post: 02-26-2005, 02:06 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