Open Workbook(s) Depending Upon Range Selected and Cell Criteria's

Ottsel

Board Regular
Joined
Jun 4, 2022
Messages
167
Office Version
  1. 365
Platform
  1. Windows
I'm trying to throw together a macro that'll important data automatically from other workbooks. Currently, I have to open the workbook, copy and PasteSpecial Paste:=xlPasteValues values into the designated cells, close the workbook, then search for the next one.

I believe I can throw together the copy and paste section, but I'm struggling with getting to the first part

Here's the file pathway I'll always be searching:
G:\Jobs\"info in cell G1 contains this folders name"\"info in cell A1 contains this folders name"\"LOT*" & "range*"

* LOT: every excel file begins with "LOT" followed by a number
* Range: A2:A10 will contain the number of the lot I'm attempting to extract data from.

For the range approach I was thinking of using an inputbox that'll have the user select what is needed to be imported.

VBA Code:
    'Idea for multiple lot numbers AKA the RANGE
    Dim rng As Range
    Set rng = Application.InputBox("Select which lots will be imported:", "Test, Inc", Type:=8)

So I have 2 problems total:
1. How to format the pathway to pickup the cell data within the worksheet - it'll be the activesheet when ran.
2. How to add the number range for the file into an index or lookup somehow.
This being the most challenging part of this start up. After the file is opened, I'll insert a copy and paste code for the data I need. It'll insert the data into the sheet. Here's an example:
Builder Differences - PROJECT_ALPHA.xlsm
ABCDEFG
1CMTPCADDRESSPLANELEVTESTBZR
21020
31021
41025
51028
61030
71100
81101
91102
101103
WAC


The idea is to open the workbook using the custom file pathway, extract what is needed into row B, C, D, E, & F, then close that workbook and proceed onto the next workbook until no one workbooks can be selected.

Any tips, advice, different approaches or code to test would be greatly appreciated.
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.

Forum statistics

Threads
1,216,107
Messages
6,128,866
Members
449,475
Latest member
Parik11

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