+ Reply to Thread
Results 1 to 2 of 2

Unable to LOOP

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-14-2012
    Location
    Melbourne
    MS-Off Ver
    Excel 2007
    Posts
    133

    Unable to LOOP

    This is what I have come up with so far.
    But as soon as it opens the file stated in cell (1,2), it fails to go to (2,2)

    Sub Macro1()
    r = 1
    sfiledir = Cells(1, 12)
    sfile = Dir(sfiledir)
    
    Do
        
        
        sfile = Dir(sfiledir & Cells(r, 2))
        'Defining sFile into a P file IF found
           
        If sfile <> "" Then Cells(r, 10) = "Y"
        'If sFile is not blank, or if found something, then register a YES
        
        
        Dim filepath As String
        filepath = "I:\" & sfile
        
        Workbooks.Open Filename:=filepath
    
        r = r + 1
        'go to next
      
    
    Loop Until Cells(r, 2) = ""
    
    End Sub

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,524

    Re: Unable to LOOP

    You are not doing anything to the workbook when you are opening it.

    Loop Until Cells(r, 2) = "" .....is now in the active worksheet because you never closed the 1st workbook after you opened it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Unable to run a loop only to a particular sheet
    By Rem0ram in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 08-27-2014, 01:06 AM
  2. Loop through multiple files and call macros (but unable to loop)
    By ryanpetersen in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-23-2014, 12:04 PM
  3. [SOLVED] Unable to Loop Function Properly
    By pgtgogo in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-18-2014, 05:41 AM
  4. Unable to create this loop in Macro!!!
    By kirkoven in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-19-2013, 01:31 AM
  5. Loop Function unable to loop
    By Junior728 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-28-2005, 06:05 AM

Tags for this Thread

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