Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
hi,
excuse me. I did spot an extra do. up near the top after i=1. but i'm still counting an odd numer of ifs and end ifs. Regards FSt1 "FSt1" wrote: hi, based on the code you posted, I count 3 ifs and 4 end ifs. 3 ifs and end ifs before the do loop and 1 end if inside the do loop(without an if). count all your ifs and end ifs and make sure you have 1 for 1. post back with results. regards FSt1 "N.F" wrote: Thanks for your help, but now that I deleted that End if statement Now I get an error saying "Block If without End If " error "FSt1" wrote: hi looks like you have 1 too many end if statements at the bottom just before end sub. if you don't have an end if for each if when using a do statement, you will get the do without a loop error message. yeah, i know. confusing. regards FSt1 "N.F" wrote: Hello, I am trying to figure out what is wrong with my code but cannot figure it out Anyone?? Thank you so much in advance. im sure the solution is simple im just not seeing it! I keep getting a compile error: " Do without Loop" Heres part of my code; Sub GenerateTextFile() Dim Coll As Integer ' output column index Dim HeaderRow As Long Dim Heading1 As String Dim Heading2 As String Dim Heading3 As String HeaderRow = Range("Header").Row ' get location of header row. Heading1 = Sheets("Sheet1").Cells(HeaderRow, 2) ' get headings Heading2 = Sheets("Sheet1").Cells(HeaderRow, 3) Heading3 = Sheets("Sheet1").Cells(HeaderRow, 4) Sheets("Output").Cells.ClearContents ' clear output sheet Roww = HeaderRow + 1 ' first row i = 1 Do Coll = 1 Sheets("Output").Cells(i, Coll) = "&D" ' First field If Sheets("Sheet1").Cells(Roww, 2) < "" Then Coll = Coll + 1 ' bump column index Sheets("Output").Cells(i, Coll) = " " & Heading1 & "=" & Sheets("Sheet1").Cells(Roww, 2) & "." ' First field End If If Sheets("Sheet1").Cells(Roww, 3) < "" Then Coll = Coll + 1 ' bump column index Sheets("Output").Cells(i, Coll) = " " & Heading2 & "=" & Sheets("Sheet1").Cells(Roww, 3) & "." ' First field End If If Sheets("Sheet1").Cells(Roww, 4) < "" Then Coll = Coll + 1 ' bump column index Sheets("Output").Cells(i, Coll) = " " & Heading3 & "=" & Sheets("Sheet1").Cells(Roww, 4) & "." ' First field End If Do Coll = Coll + 1 ' bump column index Sheets("Output").Cells(i, Coll) = "/" ' last slash Roww = Roww + 1 ' next row i = i + 1 Loop While Sheets("Sheet1").Cells(Roww, 1) < "" End If End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
error in this code | Excel Worksheet Functions | |||
Code Error | Excel Discussion (Misc queries) | |||
Error handling in this code | Excel Discussion (Misc queries) | |||
Error Code 481 | Excel Discussion (Misc queries) | |||
Code error ?? | Excel Discussion (Misc queries) |