Chelsea0270516
New Member
- Joined
- Oct 15, 2015
- Messages
- 32
Hello! I am currently working through some tutorials on youtube to help me figure out the syntax for VBA. While doing this I hit a road block - I am getting an error BUT I (think anyway) am following along exactly as the video does. And it works in the video.
If the cells A7 & B7 are empty the code should prompt the user to fill them out. But I get an Compile error: Else without If. BUT this code matches exactly what the video is doing...(minus the reference cells but I have that part down pat and the error isn't related to that)
Am I missing something? I just started using the _ so that could be wrong...
[TABLE="class: outer_border, width: 500"]
<tbody>[TR]
[TD]Sub tutorial17()
If ThisWorkbook.Sheets("Sheets2").Range("A7").Value = "" _
Or ThisWorkbook.Sheets("Sheets2").Range("B7").Value = "" _
Then MsgBox "Please fill in all details."
Else
End If
End Sub
[/TD]
[/TR]
</tbody>[/TABLE]
If the cells A7 & B7 are empty the code should prompt the user to fill them out. But I get an Compile error: Else without If. BUT this code matches exactly what the video is doing...(minus the reference cells but I have that part down pat and the error isn't related to that)
Am I missing something? I just started using the _ so that could be wrong...
[TABLE="class: outer_border, width: 500"]
<tbody>[TR]
[TD]Sub tutorial17()
If ThisWorkbook.Sheets("Sheets2").Range("A7").Value = "" _
Or ThisWorkbook.Sheets("Sheets2").Range("B7").Value = "" _
Then MsgBox "Please fill in all details."
Else
End If
End Sub
[/TD]
[/TR]
</tbody>[/TABLE]