+ Reply to Thread
Results 1 to 4 of 4

End IF without block IF compile error

  1. #1
    Registered User
    Join Date
    09-06-2017
    Location
    portland, oregon
    MS-Off Ver
    2016
    Posts
    33

    End IF without block IF compile error

    I am trying to run this macro to shift data up on multiple sheets after the rows have been deleted. I keep getting a compile error "End if Without Block If"

    Here is my vba code:

    Sub shiftmeup()


    Dim ws As Worksheet
    Dim wb As Workbook
    Set wb = ThisWorkbook
    Set ws = wb.Sheets("contactunder") '/// The underhood of my contacts
    Set ws1 = wb.Sheets("Deposits")
    Set ws2 = wb.Sheets("Lending")
    Set ws3 = wb.Sheets("Client Notes")

    With ws.Range("D11:BJ392")
    For i = .Rows.Count To 1 Step -1
    If IsEmpty(.Cells(i, 1)) Then .Rows(i).Delete Shift:=xlUp
    Next

    With ws1.Range("E11:l392")
    For i = .Rows.Count To 1 Step -1
    If IsEmpty(.Cells(i, 1)) Then .Rows(i).Delete Shift:=xlUp
    Next


    With ws2.Range("E11:Y392")
    For i = .Rows.Count To 1 Step -1
    If IsEmpty(.Cells(i, 1)) Then .Rows(i).Delete Shift:=xlUp
    Next

    With ws3.Range("E11:E392")
    For i = .Rows.Count To 1 Step -1
    If IsEmpty(.Cells(i, 1)) Then .Rows(i).Delete Shift:=xlUp

    End If
    Next
    End With
    End Sub

  2. #2
    Valued Forum Contributor kasan's Avatar
    Join Date
    07-22-2009
    Location
    Riga, Latvia
    MS-Off Ver
    Excel 2010
    Posts
    680

    Re: End IF without block IF compile error

    Hi,
    Please use code tags.
    And what happen if you remove "End If"? This line is not needed there.

  3. #3
    Registered User
    Join Date
    09-06-2017
    Location
    portland, oregon
    MS-Off Ver
    2016
    Posts
    33

    Re: End IF without block IF compile error

    I have removed the last End If and inputted 3 more "End With" at the end, code is now working fine. Thanks for your help!

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 insider Version 2505 Win 11
    Posts
    24,754

    Re: End IF without block IF compile error

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Click on Edit to open your thread, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Compile error - Block if without End if
    By BryceVBA in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-06-2017, 10:40 AM
  2. Compile Error: End IF without Block IF
    By zsparrow in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-11-2016, 10:11 PM
  3. [SOLVED] Compile error: Block If without End If
    By mdovey in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-03-2014, 02:01 PM
  4. Compile error. End if without block if
    By ezra_29 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 03-13-2013, 08:05 AM
  5. Excel 2007 : Compile Error: Block if without end if
    By F1lm1 in forum Excel General
    Replies: 2
    Last Post: 08-09-2011, 01:02 PM
  6. Compile Error: Block If without End if
    By blackmanofsteel40@gmail.com in forum Excel General
    Replies: 5
    Last Post: 03-03-2006, 02:35 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1