Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
Yet Another For without Next Error
Sub Bubbles()
Dim MyFileSystem, MyFolder, f1, FilesQ, s, myFile, MyCake Set MyFileSystem = CreateObject("Scripting.FileSystemObject") Set MyFolder = MyFileSystem.GetFolder("C:\Documents and Settings\My Documents\Inventory Stuff") Set FilesQ = MyFolder.Files Dim xDate As Integer Dim xTime As Integer Let xDate = 0 Let xTime = 0 Dim DateInt As Integer Dim TimeInt As Integer Dim Cake As Boolean For Each f1 In FilesQ s = Split(f1.Name, "_", -1, vbTextCompare) Let Cake = (IsNumeric(s(1)) And IsNumeric(s(2))) * If Cake = False Then Next DateInt = CInt(s(1)) TimeInt = CInt(s(2)) If DateInt = xDate Then If TimeInt xTime Then 'Set DateInt = xDate 'Set TimeInt = xTime 'Set myFile = f1 End If End If Next f1 MyCake = MsgBox(myFile.Name, 65, "MsgBox Example") End Sub Whenever I run this, I get a "For without Next Error" on the starred line. I've tried making it a block with an End If, and things run if I comment it out. Why might this be? |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
Yet Another For without Next Error
Sub Bubbles()
Dim MyFileSystem, MyFolder, f1, FilesQ, s, myFile, MyCake Set MyFileSystem = CreateObject("Scripting.FileSystemObject") Set MyFolder = MyFileSystem.GetFolder("C:\Documents and Settings\My Documents\Inventory Stuff") Set FilesQ = MyFolder.Files Dim xDate As Integer Dim xTime As Integer Let xDate = 0 Let xTime = 0 Dim DateInt As Integer Dim TimeInt As Integer Dim Cake As Boolean For Each f1 In FilesQ s = Split(f1.Name, "_", -1, vbTextCompare) Let Cake = (IsNumeric(s(1)) And IsNumeric(s(2))) If Cake < False Then DateInt = CInt(s(1)) TimeInt = CInt(s(2)) If DateInt = xDate Then If TimeInt xTime Then 'Set DateInt = xDate 'Set TimeInt = xTime 'Set myFile = f1 End If End If End If Next f1 MyCake = MsgBox(myFile.Name, 65, "MsgBox Example") End Sub -- --- HTH Bob (change the xxxx to gmail if mailing direct) wrote in message oups.com... Sub Bubbles() Dim MyFileSystem, MyFolder, f1, FilesQ, s, myFile, MyCake Set MyFileSystem = CreateObject("Scripting.FileSystemObject") Set MyFolder = MyFileSystem.GetFolder("C:\Documents and Settings\My Documents\Inventory Stuff") Set FilesQ = MyFolder.Files Dim xDate As Integer Dim xTime As Integer Let xDate = 0 Let xTime = 0 Dim DateInt As Integer Dim TimeInt As Integer Dim Cake As Boolean For Each f1 In FilesQ s = Split(f1.Name, "_", -1, vbTextCompare) Let Cake = (IsNumeric(s(1)) And IsNumeric(s(2))) * If Cake = False Then Next DateInt = CInt(s(1)) TimeInt = CInt(s(2)) If DateInt = xDate Then If TimeInt xTime Then 'Set DateInt = xDate 'Set TimeInt = xTime 'Set myFile = f1 End If End If Next f1 MyCake = MsgBox(myFile.Name, 65, "MsgBox Example") End Sub Whenever I run this, I get a "For without Next Error" on the starred line. I've tried making it a block with an End If, and things run if I comment it out. Why might this be? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Custom error bars not working | Charts and Charting in Excel | |||
Formula Problem - interrupted by #VALUE! in other cells!? | Excel Worksheet Functions | |||
Problem Opening an Excel File MSO9.DLL Error | Links and Linking in Excel | |||
error "module not found" | Excel Discussion (Misc queries) | |||
#REF error | Excel Worksheet Functions |