ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Activate an Excel spreadsheet using wildcard name (https://www.excelbanter.com/excel-programming/309405-activate-excel-spreadsheet-using-wildcard-name.html)

Dennis

Activate an Excel spreadsheet using wildcard name
 
Have a visual basic macro to parse info from excel sheet
to another excel sheet with consolidated info.
Ex: Parse all of the inventory items from "location
A.xls" to "consolidated inventory.xls" sheet.
Question: how do I get the macro to parse the info from
the sheet I want, whatever that sheets name is. I.E. I
want to parse from "location A.xls" sheet, "location
B.xls" sheet etc. The macro needs to give me the option
of selecting the sheet I want to parse from, or, if I can
use wildcard (*.xls) in the macro, even better.
Thanx

Norman Jones

Activate an Excel spreadsheet using wildcard name
 
Hi Dennis,


Either select the requisite worksheet and refer to it in your code as:

Activesheet

Alternatively, put up an input box at runtime to feed the sheet name. In
your procedure add something like this:

Dim sh As Variant

Do Until sh < ""
sh = Application.InputBox( _
Prompt:="Please enter name of " _
& "Worksheet to be consolidated", _
Title:="Worksheet Name", _
Type:=2)
If sh = "False" Then Exit Sub 'User Cancelled
Loop

Then, in your code, replace the previously hard-code sheet name with the sh
object variable.


---
Regards,
Norman



"Dennis" wrote in message
...
Have a visual basic macro to parse info from excel sheet
to another excel sheet with consolidated info.
Ex: Parse all of the inventory items from "location
A.xls" to "consolidated inventory.xls" sheet.
Question: how do I get the macro to parse the info from
the sheet I want, whatever that sheets name is. I.E. I
want to parse from "location A.xls" sheet, "location
B.xls" sheet etc. The macro needs to give me the option
of selecting the sheet I want to parse from, or, if I can
use wildcard (*.xls) in the macro, even better.
Thanx





All times are GMT +1. The time now is 12:17 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com