Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

select only some sheets from a workbook through vba code so that reports can be got from those sheet

Status
Not open for further replies.

rajavj

Technical User
Aug 14, 2021
7
IN
hi to all experts here

i need to select only some sheets(excel) from the workbook programmatically(vba). the names of the sheets will be varying every day. but i have to select only some of the sheets so that i can get reports from those sheets. please can some one help in this problem.
 
 https://files.engineering.com/getfile.aspx?folder=ddb68303-6d16-4e62-88d5-1300db2742d7&file=tkf.xlsm
Here's an example of a PivotTable on Sheet1. It only refers to the SkipVought sheet, that also contains a BOS column for your sheet name.

I removed all your code. It was voluminous and pretty much useless.

There is very little VBA in this version of your workbook. Some code to FORMAT the PT and remove unused PivotItems.

You can use the BOS dropdown list to select the sheets you want to display. Its that simple.

EDIT: I think that I also do a PivotTable REFRESH in the SheetActivate Event.

As combo stated in his last remark,
combo said:
and easier responding to changed expectations of managers.
Maybe you don't know it now, but historical data is a precious commodity. Maybe you even have data from years previous on paper or in files somewhere. Sometime in the future, someone might ask a question or have an interest in knowing information about what rice production was happening in the past, maybe to compare to the present. All that data in one database (could be one table or a group of inter-related tables) and you'll have that data all ready to answer OTHER questions than the one you're answering at this time.

In fact combo may have a neater, slicker way to do this with Power Queries that I'm just not up on. But the basic "trick" is to have ALL your data in one table. Otherwise, you have a very limited and shortsighted solution that Excel is not really designed to handle easily.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
 
 https://files.engineering.com/getfile.aspx?folder=ecd85ca5-1524-4e81-a9dc-cc8397b18bf0&file=tkf_SkipVoughtPT.xlsm
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top