+ Reply to Thread
Results 1 to 5 of 5

Switch between unknown wbk name grab a value and go back

  1. #1
    Dale
    Guest

    Switch between unknown wbk name grab a value and go back

    I know this is going to easy, but for the life of me...
    I would like to be able to go thru all open workbooks and switch to one
    whose name changes all the time but has the same beginning,
    GetReadySheet_*.xls.
    I found this code

    Sub ListBooks()
    Dim wbk As Workbook
    For Each wbk In Workbooks
    MsgBox wbk.Name
    Next wbk
    End Sub

    but I don’t know enough to be able to use the
    Windows(“GetReadySheet_*.xls”).Activate to go to the GetReadySheet workbook,
    grab a cell value out of E6 and then go back to the file with the code. Any
    thoughts…


  2. #2
    J.Evans.1970@gmail.com
    Guest

    Re: Switch between unknown wbk name grab a value and go back

    Sub ListBooks()
    Dim wbk As Workbook
    Dim sValue As String
    For Each wbk In Workbooks
    If Left(wbk.Name, 13) = "GetReadySheet" Then
    sValue = wbk.Worksheets("WorkSheetName").Range("E1").Value
    End If
    Next wbk
    End Sub


  3. #3
    Valued Forum Contributor tony h's Avatar
    Join Date
    03-14-2005
    Location
    England: London and Lincolnshire
    Posts
    1,187
    Dim wbk As Workbook
    dim i as integer

    do
    i=i+1
    loop until lefT(wbk.Name,len("GetReadySheet")="GetReadySheet"

    myval=wkb.worksheets("Sheet1").range("E6")

    or some such

    hope this helps
    Quote Originally Posted by Dale
    I know this is going to easy, but for the life of me...
    I would like to be able to go thru all open workbooks and switch to one
    whose name changes all the time but has the same beginning,
    GetReadySheet_*.xls.
    I found this code

    Sub ListBooks()
    Dim wbk As Workbook
    For Each wbk In Workbooks
    MsgBox wbk.Name
    Next wbk
    End Sub

    but I don’t know enough to be able to use the
    Windows(“GetReadySheet_*.xls”).Activate to go to the GetReadySheet workbook,
    grab a cell value out of E6 and then go back to the file with the code. Any
    thoughts…

  4. #4
    Dale
    Guest

    Re: Switch between unknown wbk name grab a value and go back

    Works great but I did not notice before the worksheet does not have a
    standard name either. What would I do fo ("WorkSheetName") ?

    "J.Evans.1970@gmail.com" wrote:

    > Sub ListBooks()
    > Dim wbk As Workbook
    > Dim sValue As String
    > For Each wbk In Workbooks
    > If Left(wbk.Name, 13) = "GetReadySheet" Then
    > sValue = wbk.Worksheets("WorkSheetName").Range("E1").Value
    > End If
    > Next wbk
    > End Sub
    >
    >


  5. #5
    Dave Peterson
    Guest

    Re: Switch between unknown wbk name grab a value and go back

    If you only have one worksheet in that "getreadysheet*.xls" workbook, then you
    could use:

    sValue = wbk.Worksheets(1).Range("E1").Value

    If you have more than one worksheet, how do you know which one to use?

    Dale wrote:
    >
    > Works great but I did not notice before the worksheet does not have a
    > standard name either. What would I do fo ("WorkSheetName") ?
    >
    > "J.Evans.1970@gmail.com" wrote:
    >
    > > Sub ListBooks()
    > > Dim wbk As Workbook
    > > Dim sValue As String
    > > For Each wbk In Workbooks
    > > If Left(wbk.Name, 13) = "GetReadySheet" Then
    > > sValue = wbk.Worksheets("WorkSheetName").Range("E1").Value
    > > End If
    > > Next wbk
    > > End Sub
    > >
    > >


    --

    Dave Peterson

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1