Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

End if without block if compile error 1

Status
Not open for further replies.

vba317

Programmer
Mar 5, 2009
708
US
If am getting an End if without block if compile error. So I know my macro isn't correct but I'm not sure how to fix it. Any help would be appreciated.

Code:
Sub DeleteCells()
'
Dim myNum1 As Double
Dim DCells1 As Byte
Dim DCells2 As Byte
Dim Start As Byte
Dim DLoop1 As Byte
Dim LR As Double


'Enter Starting Row
myNum1 = Application.InputBox("Enter starting row")

LR = myNum1 + 6

If Range("H" & myNum1).Value > 0 Then DCells1 = 1
If DCells1 = 1 Then Range("H" & LR).Value = ""
If DCells1 = 1 Then DCells2 = myNum1
If DCells1 = 1 Then Start = myNum1 - 5
If DCells1 = 1 Then myNum1 = Start

If DCells1 = 1 Then For DLoop1 = Start To DCells2

If DCells1 = 1 Then Range("J" & DCells2).Value = ""
If DCells1 = 1 Then Range("K" & DCells2).Value = ""
If DCells1 = 1 Then Range("L" & DCells2).Value = ""
If DCells1 = 1 Then Range("M" & DCells2).Value = ""

If DCells1 = 1 Then Next DLoop1


'
End Sub
 
Hmm, something like this:
Code:
Dim myNum1 As Double
Dim DCells1 As Byte
Dim DCells2 As Byte
Dim Start As Byte
Dim DLoop1 As Byte
Dim LR As Double


'Enter Starting Row
myNum1 = Application.InputBox("Enter starting row")

LR = myNum1 + 6

If Range("H" & myNum1).Value > 0 Then

    DCells1 = 1
    Range("H" & LR).Value = ""
    DCells2 = myNum1
    Start = myNum1 - 5
    myNum1 = Start
    
    For DLoop1 = Start To DCells2
        Range("J" & DLoop1).Value = ""
        Range("K" & DLoop1).Value = ""
        Range("L" & DLoop1).Value = ""
        Range("M" & DLoop1).Value = ""
    Next DLoop1
    
End If
Is that close to what you're after?

Hope this helps

HarleyQuinn
---------------------------------
Carter, hand me my thinking grenades!

Get the most out of Tek-Tips, read FAQ222-2244: How to get the best answers before post

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top