VBA vlookup using listbox value

kntrigirl1908

New Member
Joined
Apr 20, 2020
Messages
4
Office Version
  1. 2013
Platform
  1. Windows
Hello all! How do I reference the listbox value in my vlookup formula?

I have a workbook with several worksheets that will be individually exported and saved as new workbooks with unique file paths and file names. For ease and time, I've created a list box of worksheet names that the user can select. Based on the this selection, a macro will lookup the desired file path and name, export the worksheet, save the new workbook using the vlookup values based on the list box selection.
My data range, FluxWs, includes a list of worksheet names with the proper file path and file name. But I'm stuck on how to reference the listbox value in my vlookup formula. Any suggestions?

Dim destFilePath As String
Dim destFileName As String

'destFilePath = Application.WorksheetFunction.VLookup(listbox value syntax?, Range("FluxWs"), 4, 0)
destFileName = Application.WorksheetFunction.VLookup(list box value syntax?, Range("FluxWs"), 5, 0)

Application.DisplayAlerts = False

ThisWorkbook.Sheets(SheetArray()).Move Before:=Workbooks.Add.Sheets(1)
ActiveWorkbook.Sheets("Sheet1").Delete
Application.ActiveWorkbook.SaveAs Filename:=destFilePath & destFileName, FileFormat:=xlWorkbookNormal
ActiveWorkbook.Close
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,214,653
Messages
6,120,748
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top