Fixing Excel VBA (Macro) Compile Error For Next, Do Loop, While Wend

Fixing Excel VBA (Macro) Compile Error For Next, Do Loop, While Wend

EverydayVBA

8 лет назад

16,363 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Sachin Mane
Sachin Mane - 30.03.2020 10:16

How to resolve run time error 438

Ответить
akshay dey
akshay dey - 01.05.2018 19:57

fuck you man where is fixing???

Ответить
Muzzammil Vora
Muzzammil Vora - 22.01.2018 09:51

give the solution instead of telling problems ?

Ответить
Martrica Allumns
Martrica Allumns - 31.07.2016 22:05

Hello, I have an issue with a loop. I have an End IF within my loop. I would like to add loop in another file with the exact same code. However I am getting the message for a Compile Error without Do. Here is my code with loop. FYI: This is my first time writing macros.  Sub Auto_Open()
 
 
 Dim FileSys As FileSystemObject
    Dim objFile As File
    Dim myFolder As Object
    Dim strFilename As String
    Dim dteFile As Date
       
    Const myDir As String = "G:\S\Staffing\Attendance\July 2016"
   
    Set FileSys = New FileSystemObject
    Set myFolder = FileSys.GetFolder(myDir)
   
    Set FileSys = New FileSystemObject
    Set myFolder = FileSys.GetFolder(myDir)
   
    dteFile = DateSerial(1900, 1, 1)
    For Each objFile In myFolder.Files
        If objFile.DateLastModified > dteFile Then
            dteFile = objFile.DateLastModified
            strFilename = objFile.path
     End If
    Next objFile
 
    Workbooks.Open strFilename
           
    Set FileSys = Nothing
    Set myFolder = Nothing
   Windows("dashboard.xlsm").Activate
   
  End If
   
   Loop
 Dim FileSys As FileSystemObject
    Dim objFile As File
    Dim myFolder As Object
    Dim strFilename As String
    Dim dteFile As Date
       
    Const myDir As String = "G:\S\Staffing\Headcount\July 2016 "
   
    Set FileSys = New FileSystemObject
    Set myFolder = FileSys.GetFolder(myDir)
   
    Set FileSys = New FileSystemObject
    Set myFolder = FileSys.GetFolder(myDir)
   
    dteFile = DateSerial(1900, 1, 1)
    For Each objFile In myFolder.Files
        If objFile.DateLastModified > dteFile Then
            dteFile = objFile.DateLastModified
            strFilename = objFile.path
     End If
    Next objFile
 
    Workbooks.Open strFilename
           
    Set FileSys = Nothing
    Set myFolder = Nothing
   Windows("dashboard.xlsm").Activate
   
  End If
   
   Loop  End Sub

Ответить