Want to check if cell is blank before running macro

M

Munchkin

I'm only entering part of my macro button because it's long.

The first thing I want my macro to do is look at D4 & give an error message
if the cell is blank. How do I do that?



Sheets("REQUEST ").Select
ActiveSheet.Unprotect
Rows("4:4").Select
Selection.Insert Shift:=xlDown
Application.Goto Reference:="NewRecord"
Selection.Copy
Rows("4:4").Select
ActiveSheet.Paste
Range("A4").Select
Application.CutCopyMode = False
Selection.Copy
Range("D4").Select
Sheets("SEARCH ").Select
Range("D9:E9").Select
Application.CutCopyMode = False
 
D

Don Guillett

Without seeing all, try these ideas

with Sheets("REQUEST ")
If Len(Application.Trim(.Range("d4"))) < 1 Then
MsgBox "bad"
Exit Sub
End If
'MsgBox "go on "

.Unprotect

.Rows("4).insert

range("NewRecord").copy .cells(4,"a")
'etc
Sheets("SEARCH ").Range("D9:E9").copy ' ??

end with
end sub
 
E

eliano

I'm only entering part of my macro button because it's long.

The first thing I want my macro to do is look at D4 & give an error message
if the cell is blank.  How do I do that?

Sheets("REQUEST ").Select
    ActiveSheet.Unprotect
    Rows("4:4").Select
    Selection.Insert Shift:=xlDown
    Application.Goto Reference:="NewRecord"
    Selection.Copy
    Rows("4:4").Select
    ActiveSheet.Paste
    Range("A4").Select
    Application.CutCopyMode = False
    Selection.Copy
    Range("D4").Select
    Sheets("SEARCH ").Select
    Range("D9:E9").Select
    Application.CutCopyMode = False

Hi Munchin.
the macro part is quite incomprehensible; however you can use:

........
If Range("D4").Value = "" then
' make something
Else
' make something else
End If
.......

Regards
Eliano
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top