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
 

Some videos you may like

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,134
Office Version
  1. 365
Platform
  1. Windows
Try
Code:
If IsEmpty(Range("C4")) = True Then
 

SallyMcK

New Member
Joined
Nov 21, 2017
Messages
7
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
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
46,134
Office Version
  1. 365
Platform
  1. Windows
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
 

SallyMcK

New Member
Joined
Nov 21, 2017
Messages
7
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
 

Watch MrExcel Video

Forum statistics

Threads
1,108,732
Messages
5,524,513
Members
409,583
Latest member
RedHelp

This Week's Hot Topics

Top