473,382 Members | 1,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Selecting Sheets (Excel)

18
I need to select a group of sheets, where the inclusion of each sheet in the workbook is based on a value in each sheet. (For example, select all sheets which have a 1 in cell A1.)

How can I do this in VisualBasic?

Bertie
Apr 19 '07 #1
2 1913
SammyB
807 Expert 512MB
I need to select a group of sheets, where the inclusion of each sheet in the workbook is based on a value in each sheet. (For example, select all sheets which have a 1 in cell A1.)

How can I do this in VisualBasic?

Bertie
Expand|Select|Wrap|Line Numbers
  1. Sub SelectOne()
  2.     Dim s() As String
  3.     Dim ws As Worksheet
  4.     Dim i As Integer
  5.     i = 0
  6.     For Each ws In Worksheets
  7.         If ws.Cells(1, 1).Value = 1 Then
  8.             ReDim Preserve s(i)
  9.             s(i) = ws.Name
  10.             i = i + 1
  11.         End If
  12.     Next ws
  13.     Worksheets(s).Select
  14. End Sub
HTH --Sam
Apr 19 '07 #2
EByker
18
Expand|Select|Wrap|Line Numbers
  1. Sub SelectOne()
  2.     Dim s() As String
  3.     Dim ws As Worksheet
  4.     Dim i As Integer
  5.     i = 0
  6.     For Each ws In Worksheets
  7.         If ws.Cells(1, 1).Value = 1 Then
  8.             ReDim Preserve s(i)
  9.             s(i) = ws.Name
  10.             i = i + 1
  11.         End If
  12.     Next ws
  13.     Worksheets(s).Select
  14. End Sub
HTH --Sam
Thanks a lot! Problem solved!

Regards, B
Apr 20 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Ilan | last post by:
Hi all I need to add data from two Excel sheets (both on the same workbook) to an existing table in my SQL DB. The problem is that each sheet holds different fields for the same record, though...
2
by: Osiris Sawiris | last post by:
I inherited an Inventory control application that updates the stock from the branches at the end of each day. We receive the stock transactions via e-mail attachments (Excel Sheets). Those...
4
by: sunilkeswani | last post by:
I need help with exporting data from 2 access tables, into 2 existing spreadsheets in a single Excel file. Currently, I am using this code: DoCmd.TransferSpreadsheet acExport, 8, "Table1",...
4
by: Hitesh | last post by:
Hi, I have three datagrid control on my aspx page and one export to excel button, i want to export all the 3 datagrids contents in one excel file. how can i achive that? -- Thanks Hitesh
0
by: SirMikesALot | last post by:
I'm pretty good at Excel, but my skills in Visual Basic are very limited. I found script on-line that creates & opens a user form, allows you to select your worksheets, prints the selected...
1
by: dwmaillist | last post by:
Hello, I am interested in extracting the information from an excel workbook with many sheets in it and outputting a csv like text file. Since I want a single file with all information for all...
0
by: acarrazco | last post by:
Hello, I am totaly new to VBA and I'm trying to modify a macro that was given to me but it doesn't seem to be working. I'm trying to extract data from three excel spreadsheets, put it into a combined...
4
by: Harshe | last post by:
hello all, I am trying to code, but i am just stuck after importing one sheet. so here is the gist of what i need help with. In a workbook at the start of the year (january) i will have 4...
2
by: deve8ore | last post by:
Hello, I'm working with Adobe Reader 8.0, working on a project for work, so not allowed to download any other software/ freeware. We receive PDF files frequently with about 20 sheets. I'd like...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.