I have the code below, however it is returnng a compile error: "Block If without End If" on the last End If row (I have bold the row). You do not have to declare State in this case but it is good practice when you are using the variable in a loop So when you put that End If there it is expecting an If statement with lines after it. I'm getting an "End If without block If". Best Regards, Asadulla Javed Hi All, I am trying to set a vba code to revert to a single layout when closing a workbook. End Sub. This syntax includes the End If statement, as shown in the following example. Cause in VBA IF block can be of single line if i) only true part is required and ii) Only one instruction is there. Try adding two more End If lines... â jamheadart Jan 11 '18 at 19:56 Either that your use ElseIf â K.Dá´á´ Éªs Jan 11 '18 at 19:58 Looks like you need to replace the 2nd and 3rd If with ElseIf or make a Select...Case statement. â aggaton Jan 11 '18 at 19:58 To run more than one line of code, you must use the multiple-line syntax. Aug 10, 2016 #1 Hi Guys, I hope you are all well :-)" End If End With End Sub. I tried to change the place of "End IF", but it resulted in another warning "Block end if without if". Thread starter bloodmilksky; Start date Aug 10, 2016; Tags end if without block if macro vba & excel 2010 B. bloodmilksky Board Regular. I am getting the same compile error: "End If without Block If". Else: MsgBox "Oh good your on your way. If the "AddItem" appears in same line VB Editor, it will be complete IF Block and "Range ("B6").Value = Target.Row" will be outside of IF Block. What have I done wrong. Sub Test2() With ThisWorkbook.ActiveSheet If Len(Range("A1")) = 0 Then MsgBox "Get Cracking!" I am very new to VBA. end if without block if If this is your first visit, be sure to check out the FAQ by clicking the link above. The following code keeps getting warning regarding "Block if without End if". I'd prefer a method of putting both paragraphs within the 1 "IF", just for convenience/ brevity. My code is as below. Please guide. It is completely valid syntax to have an If statement all on one line without an End If. I tried to calculate median for a vector. 'EN If Range("aaj1") = 1 Then Range("aai3:aai182").Select Selection.Copy Sub UPDATE() Dim temp As Integer 'stock_list is the current stock level used to avoid errors such as adjusting itself; Dim row_stock As Integer â¦ END IF WITHOUT BLOCK IF VBA Problems. So that last "End If" is considered extra and error raised. These two would be valid without an error If TotalDaysLate > 15 then CountE = CountE + 1 Part of a macro is below. To get over the problem do I have to put "End if" after " ActiveSheet.Paste" then begin another "If" block? Disclaimer: I'm a total VBA novice and am attempting to piece code together. Please help. You may have to register before you can post: click the register link above to proceed. Thanks. Sub Process() Close Open "D:\New folder\Plates.txt" For Input As #1 Open "D:\New folder\Output.txt" For Output As #2 Do Joined Feb 3, 2016 Messages 202. There is an alternative block for 'PN. Your input would be appreciated. Sub AlertUser(value as Long) If value = 0 Then AlertLabel.ForeColor = "Red" AlertLabel.Font.Bold = True AlertLabel.Font.Italic = True End If End â¦ I am not able to figure out how to solve this.