Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
error VBA next without for
Hi,
Have some code below which give me an Error: Next without for. What Am I Doing Wrong?? Cheers, Harold Sub test2() ScreenUpdating = False Dim Dir As String Dim Wbk As String Dim Sht As String Dim Num As String For a = 5 To 8 Dir = Sheets("print").Range("B" & a).Value Wbk = Sheets("print").Range("C" & a).Value Sht = Sheets("print").Range("D" & a).Value Num = Sheets("print").Range("E" & a).Value If a 7 Then ChDir (Dir) Workbooks.Open Filename:=Wbk, _ UpdateLinks:=3 With Sheets(Sht).PageSetup .LeftFooter = "&8&Z&F - &A" .RightFooter = "&8&D - &T & " & Num End With Sheets(Sht).PrintOut Next a End Sub |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
error VBA next without for
On Tue, 11 Dec 2007 16:02:43 -0800 (PST), mohavv wrote:
Hi, Have some code below which give me an Error: Next without for. What Am I Doing Wrong?? Cheers, Harold Sub test2() ScreenUpdating = False Dim Dir As String Dim Wbk As String Dim Sht As String Dim Num As String For a = 5 To 8 Dir = Sheets("print").Range("B" & a).Value Wbk = Sheets("print").Range("C" & a).Value Sht = Sheets("print").Range("D" & a).Value Num = Sheets("print").Range("E" & a).Value If a 7 Then ChDir (Dir) Workbooks.Open Filename:=Wbk, _ UpdateLinks:=3 With Sheets(Sht).PageSetup .LeftFooter = "&8&Z&F - &A" .RightFooter = "&8&D - &T & " & Num End With Sheets(Sht).PrintOut Next a End Sub You are missing the end if to terminate the: If a 7 then ... ... With Sheets ... ... End With ????? end if ????? --ron |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Error: "Excel encountered an error and had to remove some formatti | Excel Discussion (Misc queries) | |||
Counting instances of found text (Excel error? Or user error?) | Excel Worksheet Functions | |||
I have Error 1919 Error Configuring ODBC dataSource Database | Excel Discussion (Misc queries) | |||
Excel 2003 Macro Error - Runtime error 1004 | Excel Discussion (Misc queries) |