VBA: Show Message "Empty Data" Into A Range
-
- 3StarLounger
- Posts: 243
- Joined: 17 Feb 2022, 05:16
VBA: Show Message "Empty Data" Into A Range
hi all..
i have a sheet that contains data,formula, merge cell and coloring background & no coloring
i want to check cells only that empty data / empty cell into no coloring cell, with step like this
1. click the vba code;
2. select range that to running, ok
3. show message/info "No Empty " or "Cell C2 is Empty or Cells C2,C3 are Empty, etc......."
the code running well in any name sheets.
here attachment file.
anyone help, greatly appreciated..
.susant
i have a sheet that contains data,formula, merge cell and coloring background & no coloring
i want to check cells only that empty data / empty cell into no coloring cell, with step like this
1. click the vba code;
2. select range that to running, ok
3. show message/info "No Empty " or "Cell C2 is Empty or Cells C2,C3 are Empty, etc......."
the code running well in any name sheets.
here attachment file.
anyone help, greatly appreciated..
.susant
You do not have the required permissions to view the files attached to this post.
-
- Administrator
- Posts: 79324
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: VBA: Show Message "Empty Data" Into A Range
See the attached workbook.
You do not have the required permissions to view the files attached to this post.
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 243
- Joined: 17 Feb 2022, 05:16
Re: VBA: Show Message "Empty Data" Into A Range
hi Hans, thank you so much. Working well.
-
- 3StarLounger
- Posts: 243
- Joined: 17 Feb 2022, 05:16
Re: VBA: Show Message "Empty Data" Into A Range
hi hans, i think i need modify your code
the code work included hidden cell/rows, how to make/modify the code only work in visible cells
thanks for your time
Code: Select all
Sub test()
Dim rng As Range
Dim cel As Range
Dim msg As String
On Error Resume Next
Set rng = Application.InputBox(Prompt:="Select a range", Type:=8)
On Error GoTo 0
If rng Is Nothing Then
Beep
Exit Sub
End If
For Each cel In rng
If cel.Value = "" And cel.Interior.ColorIndex = xlColorIndexNone Then
msg = msg & ", " & cel.Address(False, False)
End If
Next cel
If msg = "" Then
MsgBox "No empty uncolored cells.", vbInformation
Else
MsgBox "The following uncolored cells are empty:" & vbCrLf & Mid(msg, 3), vbInformation
End If
End Sub
thanks for your time
-
- Administrator
- Posts: 79324
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: VBA: Show Message "Empty Data" Into A Range
Change the line
to
Code: Select all
If cel.Value = "" And cel.Interior.ColorIndex = xlColorIndexNone Then
Code: Select all
If cel.Value = "" And cel.Interior.ColorIndex = xlColorIndexNone And cel.Hidden = False Then
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 243
- Joined: 17 Feb 2022, 05:16
Re: VBA: Show Message "Empty Data" Into A Range
hi hans,
after change the line with, then running with new code
how to fix it?
after change the line with, then running with new code
show error message number "400".If cel.Value = "" And cel.Interior.ColorIndex = xlColorIndexNone And cel.Hidden = False Then
how to fix it?
-
- Administrator
- Posts: 79324
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: VBA: Show Message "Empty Data" Into A Range
Sorry about that. Assuming that you hide (or filter) rows:
Code: Select all
If cel.Value = "" And cel.Interior.ColorIndex = xlColorIndexNone And cel.EntireRow.Hidden = False Then
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 243
- Joined: 17 Feb 2022, 05:16
Re: VBA: Show Message "Empty Data" Into A Range
hi HansV, working well,thank you
-
- 3StarLounger
- Posts: 243
- Joined: 17 Feb 2022, 05:16
Re: VBA: Show Message "Empty Data" Into A Range
hi hans..
i think this a long time ago , the code work properly but not work properly for merged cell
if the cell contains merged cells the code not work properly
how to code work for merged cell & for too keep visible cell
here the complete code
i think this a long time ago , the code work properly but not work properly for merged cell
if the cell contains merged cells the code not work properly
how to code work for merged cell & for too keep visible cell
here the complete code
thank in advance.Sub checkemptycell()
Dim rng As Range
Dim cel As Range
Dim msg As String
On Error Resume Next
Set rng = Application.InputBox(Prompt:="Select a range", Type:=8)
On Error GoTo 0
If rng Is Nothing Then
Beep
Exit Sub
End If
For Each cel In rng
If cel.Value = "" And cel.Interior.ColorIndex = xlColorIndexNone And cel.EntireRow.Hidden = False Then
msg = msg & ", " & cel.Address(False, False)
End If
Next cel
If msg = "" Then
MsgBox "No empty uncolored cells.", vbInformation
Else
MsgBox "The following uncolored cells are empty:" & vbCrLf & Mid(msg, 3), vbInformation
End If
End Sub
-
- Administrator
- Posts: 79324
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: VBA: Show Message "Empty Data" Into A Range
In general, it is better to avoid merging cells.
Could you attach a small sample workbook that demonstrates the problem? Thanks in advance.
Could you attach a small sample workbook that demonstrates the problem? Thanks in advance.
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 243
- Joined: 17 Feb 2022, 05:16
Re: VBA: Show Message "Empty Data" Into A Range
hi hans, thanks a lot
but unfortunately , my excel file is confidential with vba & protected from my department
for information the range can selected in (I4:V22), into range contains hidden row and merged cell..
i hope this help you.
but unfortunately , my excel file is confidential with vba & protected from my department
for information the range can selected in (I4:V22), into range contains hidden row and merged cell..
i hope this help you.
-
- Administrator
- Posts: 79324
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: VBA: Show Message "Empty Data" Into A Range
I tested on a small sample workbook with merged cells in a filtered range. The code ran without errors...
So I'm afraid I cannot help.
So I'm afraid I cannot help.
Best wishes,
Hans
Hans
-
- 3StarLounger
- Posts: 243
- Joined: 17 Feb 2022, 05:16
Re: VBA: Show Message "Empty Data" Into A Range
hi hans..
thank you, i will try it again.
thank you, i will try it again.