If IsEmpty on Merged Cells Not working as should be

SallyMcK

New Member
Joined
Nov 21, 2017
Messages
7
I have some merged cells , namely C4 and D4. I am trying to run some code to check if the range (c4:D4) is empty and if so to have the msgbox popup and the macro end. It works fine but it continues to keep showing the Msgbox even after I have entered a contact name into the merged cells. I can only assume it is because the cells are merged. Can anyone help as to why this is happening after Ive entered a contact name.

Range("C4").Select
If IsEmpty(C4) = True Then
MsgBox "PLEASE ENTER CONTACT NAME"
End If
If IsEmpty(C4) = True Then Exit Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Try
Code:
If IsEmpty(Range("C4")) = True Then
 
Upvote 0
Thanks for suggestion but it still falls over once I've entered a name. Different problem occurs though - it doesn't run the rest of the macro. Its like its exited the sub
 
Upvote 0
it doesn't run the rest of the macro. Its like its exited the sub
That's because of the last line of your code.
With C4:D4 merged this works for me
Code:
Sub chk()

If IsEmpty(Range("C4")) = True Then
   MsgBox "PLEASE ENTER CONTACT NAME"
   Exit Sub
Else
   MsgBox "ok"
End If
End Sub
but if B4:C4 are merged I get your msgbox.
It's always best to avoid merging cells as they are a right royal PITA!
Try using centre across selection instead
 
Upvote 0
Thanks. Still not working but I'll give it a go again tomorrow. I'll try in a seperate worksheet and start from scratch again. Many Thanks
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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