+ Reply to Thread
Results 1 to 6 of 6

GoTo code

Hybrid View

RBI GoTo code 10-24-2008, 03:15 PM
jasoncw Use the same code posted... 10-24-2008, 03:23 PM
RBI Ya but does this work If the... 10-24-2008, 03:43 PM
jasoncw I wasn't able to test it due... 10-24-2008, 07:29 PM
mikerickson In the code in post #3... 10-25-2008, 01:23 AM
RBI Calling Macros 10-27-2008, 09:46 AM
  1. #1
    Forum Expert
    Join Date
    12-29-2004
    Location
    Michigan, USA
    MS-Off Ver
    2013
    Posts
    2,208
    I wasn't able to test it due to the amount of work that would be involved in replicating your situation, but try this code to see if it works:

    Private Sub CommandButton4_Click()
        Dim Ump As String
        Dim Mns As String
        Dim Pth As String
        Dim Mnt As String
        Dim Fln As String
        Dim Wkb As Workbook
        Dim Wks As Worksheet
        Dim Rng As Range
        Dim c As Range
        Dim i As Long
        
        Ump = Application.InputBox(Prompt:="Please Enter Cheque Date", Type:=1)
        Mnt = Month(Ump)
        Range("E54").Value = Mnt
        Mns = Range("F54").Value
        Pth = "Q:\CRS PAID FILE (Lai-Yin)\2008\" & Range("D42").Value & "_" & Mns
        Set Wks = ActiveSheet
        i = 87
        
        With Wks
            While .Cells(i, 5) <> "End"
                Fln = .Cells(i, 5).Value
                ChDir Pth
                Set Wkb = Workbooks.Open(Filename:= _
                    Pth & "\" & Fln)
                If Not Wkb Is Nothing Then
                    Set Rng = Wkb.ActiveSheet.Columns("F:F")
                    Set c = Rng.Find(What:="GE FLEET SERVICES", After:=Rng.Resize(1, 1). _
                        Offset(0, -1), LookIn:=xlFormulas, LookAt:=xlWhole, _
                        SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, _
                        SearchFormat:=False)
                    If c Is Nothing Then Wkb.Close
                    c.Activate
                    Exit Sub
                End If
                i = i + 1
            Wend
        End With
    End Sub
    Jason
    Last edited by jasoncw; 10-24-2008 at 07:31 PM.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229
    In the code in post #3
    change one line
    Nxt:    
            ActiveWindow.Close
            Resume Tst
    End Sub
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ 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