VBA error message if cell is blank

will31

Board Regular
Joined
May 2, 2010
Messages
140
Hi All,

I have this code which I need to add a message box if a cell is blank. I've managed to do this but the macro should stop if the cell is blank which I can't figure out:

Code:
Sub Order()
'
' Paste Macro
'
Application.ScreenUpdating = False
If IsEmpty(ThisWorkbook.Sheets(1).Range("D10")) Then
            MsgBox ("Please Enter the Study Number or General if not study specific")
            Cancel = True
[COLOR=magenta]End If
[/COLOR]'Enter User
Sheets("Ordering Sheet").Range("G23").Value = Application.UserName
'Paste Data
Sheets("Ordering Sheet").Range("A23:P23").Copy
Sheets("Orders").Range("A50000").End(xlUp).Offset(1).PasteSpecial Paste:=xlValues
'Clear Clipboard
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub

I suspect the purple line is missing something before or after it, any ideas?
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Try

Code:
Sub Order()
'
' Paste Macro
'
If ThisWorkbook.Sheets(1).Range("D10").Value = "" Then
            MsgBox "Please Enter the Study Number or General if not study specific"
            Exit Sub
End If
Application.ScreenUpdating = False
'Enter User
Sheets("Ordering Sheet").Range("G23").Value = Application.UserName
'Paste Data
Sheets("Ordering Sheet").Range("A23:P23").Copy
Sheets("Orders").Range("A50000").End(xlUp).Offset(1).PasteSpecial Paste:=xlValues
'Clear Clipboard
Application.CutCopyMode = False
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Hi There,

This is really useful, but i'm trying to highlight one cell in a range of multiple cells

Application.ScreenUpdating = False
If IsEmpty(ThisWorkbook.Sheets(6).Range("U76", "U229")) Then
MsgBox ("Please Review your answers, you've missed one")
Cancel = True
End If


This VBA works if all the Cells are blank, but not if just one is. Can anyone help Please?


Cheers
Ciaran
 
Upvote 0
Hi There,

This is really useful, but i'm trying to highlight one cell in a range of multiple cells

Application.ScreenUpdating = False
If IsEmpty(ThisWorkbook.Sheets(6).Range("U76", "U229")) Then
MsgBox ("Please Review your answers, you've missed one")
Cancel = True
End If


This VBA works if all the Cells are blank, but not if just one is. Can anyone help Please?
Re-posted here: https://www.mrexcel.com/forum/excel...-within-range-multiple-cells.html#post5218214

Please do not post the same question in multiple places. Per forum rules, posts of a duplicate nature are generally locked or deleted (https://www.mrexcel.com/forum/board-announcements/99490-forum-rules.html). It is usually better to post your question to a new thread rather than resurrecting old threads, so let's handle the question in your other thread.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,453
Members
448,967
Latest member
grijken

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top