yosi_lb replied...
Hi there
how can i retrive all the sheets names (or Caption) available in a workbook
and how can i find if a sheet exsist on the workbook
thak all it is a great newsgroup
Sheets
(1)
Retrive
(1)
Names
(1)
Caption
(1)
Workbook
(1)
Sheet
(1)
Exsist
(1)
Newsgroup
(1)
GarysStuden replied...
Enter and run this small macro:
Sub sheetlist()
Dim s As String
s = ""
For Each w In Worksheets
s = s & Chr(10) & w.Name
Next
MsgBox (s)
End Sub
--
Gary's Student
Michael Bednarek replied...
On Thu, 28 Dec 2006 06:52:38 +0200, yosi_lb wrote in microsoft.public.excel:
Sub ListAllSheets(wbkBook As Workbook)
Dim shtSheet As Worksheet
For Each shtSheet In wbkBook.Sheets
Debug.Print shtSheet.Name
Next shtSheet
End Sub
'========
Function SheetExists(wbkBook As Excel.Workbook, strSheetName As String) As Boolean
Dim shtSheet As Worksheet
SheetExists = True
For Each shtSheet In wbkBook.Sheets
' This is case sensitive; making it not is left as an exercise for the reader.
If shtSheet.Name = strSheetName Then Exit Function
Next shtSheet
SheetExists = False
End Function
--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"
Travelle replied...
Thank you for your macro. It lists the first 55 worksheets. Is there any way
to get more? I have a file with around 80 sheets! Also, is there a way to get
a list of the hidden sheets as well??
Gord Dibben replied...
Try this version.
Will give a list of all sheet names starting at A1 on the active sheet.
Insert a new sheet and have that sheet active when you run the macro.
Will list all sheets including hidden sheets.
Private Sub ListSheets()
'list of sheet names starting at A1
Dim rng As Range
Dim i As Integer
Set rng = Range("A1")
For Each Sheet In ActiveWorkbook.Sheets
rng.Offset(i, 0).Value = Sheet.Name
i = i + 1
Next Sheet
End Sub
Gord Dibben MS Excel MVP
On Fri, 29 Dec 2006 06:48:00 -0800, Traveller
Travelle replied...
Hi Gord,
I guess I'm one of those who knows just enough to be dangerous!
When I entered your code without the word "Private" at the beginning, it
worked perfectly. Otherwise, I couldn't find it under my list of macros!?
How does it work with the word "Private" at the beginning?
Gord Dibben replied...
Private Subs are not listed in Tools>Macro>Macros because they
are.........Private and not for viewing by snoops.
It would still work, you would just have to type the name into the dialog box
then run it.
Or assign to a button or shortcut key combo.
My error in leaving the sub as Private when posting.
Gord
On Fri, 29 Dec 2006 09:54:01 -0800, Traveller
Travelle replied...
Hi Gord,
Thanks again for the explanation. Thanks to generous folks like yourself,
people like me are able to learn and use some of the finer points of Excel
and other applications a little bit at a time, making our lives a whole lot
easier.
Travelle replied...
I am sorry . . . another stupid question: if it is a Private Sub, which dialog
box do you type the name into??
Dave Peterson replied...
Tools|Macro|macros...
Type it into the Macro Name box.
--
Dave Peterson
Travelle replied...
it is me again!
I figured it out. THANKS AGAIN!
Harlan Grove replied...
Gord Dibben wrote...
Since all procedure names are visible when viewing XLS files with a hex
editor, Private only prevents viewing by the village idiots, not
dedicated and knowledgeable snoops.
That said, better to make the procedure a function which could return
the list of worksheet names either as an array or as a long text
string. Much, much more flexible.
Function wslst(Optional rettxt As Boolean = False) As Variant
Dim rv As Variant, k As Long, wsc As Sheets
If TypeOf Application.Caller Is Range Then
Set wsc = Application.Caller.Parent.Parent.Sheets
Else
Set wsc = ActiveWorkbook.Sheets
End If
If Not rettxt Then ReDim rv(1 To wsc.Count, 1 To 1)
For k = 1 To wsc.Count
If rettxt Then
rv = rv & vbLf & wsc(k).Name
Else
rv(k, 1) = wsc(k).Name
End If
Next k
If rettxt Then
wslst = Mid(rv, 2)
Else
wslst = rv
End If
End Function
Travelle replied...
Thanks, Dave. It was not working for me until I realized you need to type the
sheet number as part of the name of the macro. That did the trick!
Harlan Grove replied...
Michael Bednarek wrote...
...
...
Wouldn't
=ISNUMBER(ROWS(INDIRECT("'"&WorksheetNameHere&"'!A1")))
accomplish the same thing without VBA?
Dave Peterson replied...
I would put this kind of macro in a General module--not behind a worksheet and
not behind ThisWorkbook.
--
Dave Peterson
Excel - How to list all sheets
Asked By Michael Bednarek
29-Dec-06 11:02 PM
On 29 Dec 2006 12:15:03 -0800, Harlan Grove wrote in
microsoft.public.excel:
Indeed it would. Thanks for that.
--
Michael Bednarek http://mbednarek.com/ "POST NO BILLS"

and clicked - it should show all the attachment realated to it. So that ppl can retrive the attachment as well. 6) Should be able to run reporting to analyze the data in the team can improvise it later. The main constrain being to upload attachment and retrive it. This database will be created in shared network, so that all the users can in one place). . Thanks in advance! Senthil Excel Programming Discussions ADODB.Connection (1) QueryTables (1) Sheets (1) Excel (1) Workbook (1) Macros (1) Yes Excel can be used to act as the Text you wish to compare GetDay = Day(GetDate) GetMonth = Month(GetDate) GetYear = Year(GetDate) Sheets("SHEETNAME").Select ' Add the Worksheet name you wish to run the sub on For a need to alter the name to ensure you don't clash with pre-defined sub names b = Day(Cells(a, 2)) ' Cells(a, #) where # is the Column number ie B = 2 LockType: = adLockOptimistic, _ Options: = adCmdTable If .EOF <> True Then .MoveLast End If End With With Sheets("Internal Project Plan") ClientName = .Range("B4") ImpMgr = .Range("B5") LaunchDate = .Range("C4") LastRow = .Range("K
Need help extracting date and time with Excel 2K Excel I have 2 sheets setup. Sheet 1 has name listed in column A and Sheet 2 has data as Column D has more text than just the name. In this example I like to retrive the latest date and time for rdupree and place it into Sheet1 Column C in I am not allowed to remove the extra text from Column D in Sheet2. Example1 - names listed in Sheet1 Column A rdupree jose debby pcaruso Example2 - type of data on Sheet dash is non-standard)? It is a little hard to tell. . . I'm assuming the names on Sheet2 are in Column C, right? Does your data start on Row 1 on both sheets or do you have a header on Row 1 and the data starts on Row column at this time. The data on Sheet 2 start on row 2 and the names on Sheet 1 Column A start on row 4. - - tech1NJ Here a better example of MVP keywords: Need, help, extracting, date, and, time, with, Excel, 2K description: I have 2 sheets setup. Sheet 1 has name listed in column A and Sheet 2 has data as
within Excel. For example, in cell A1 I have a drop-down list of vendor names, when I select Acme from this list, I would the queried information (from Access) for what ever vendor I have chosen). Any thoughts? Thanks! - - Drew Excel Programming Discussions QueryTables (1) Sheets (1) Excel (1) Worksheet (1) Macro (1) VBA (1) RefreshOnFileOpen (1) XlInsertDeleteCells (1) When pulling perform a query you can open the access database using ADO or DBO methods and retrive what is call a recordset using the SQL. You can look at the Access VBA False End With Now I replace 'Test' with a reference to the worksheet Set Pulldownbox = Sheets("sheet2").range("A1") With ActiveSheet.QueryTables.Add(Connection: = Array(Array("ODBC;" & _ _ Array(";")), _
cells Excel I have the following code to delete named cells for a worksheet: With Sheets(nme & " DB") .Names(nme & "cst1").Delete .Names(nme & "cst2").Delete .Names(nme & "cst3").Delete .Names(nme & "cst4").Delete .Names(nme & "cst5").Delete .Names(nme & "date").Delete .Names(nme & "daterng").Delete .Names(nme & "item").Delete .Names(nme & "itemno").Delete .Names(nme & "itemnum").Delete