Count empty cells and add object

Quatip

New Member
Joined
Jul 27, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi, I have 8 columns with data each column 60 rows. I want to create macro that count empty cells and if it's more than 10 not separated by filled cell will add object text box with count of empty cells. Something similar to image in attach. I checked lots of different website but have no idea with what to start ( desirable Arrow from first empty cell to last one and text box next to with count of empty cells).
 

Attachments

  • Capture.JPG
    Capture.JPG
    62.7 KB · Views: 6

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Check additonal info about column in code and run Label4EmptyRows().

VBA Code:
Sub Label4EmptyRows()
Dim z As Integer
Dim counter As Integer
Dim i As Integer
Dim lastR As Integer
Dim where As String
lastR = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row        'A as example, column with word COMPLETED in your case
For z = 1 To lastR
counter = 0
    If Cells(z, "A").Value = "" Then            'A as above
        where = Cells(z, "A").Address           'A as above
        For i = Cells(z, "A").Row To lastR      'A as above
            If Cells(i, "A").Value = "" Then    'A as above
                counter = counter + 1
            Else
                z = z + counter
                Exit For
            End If
        Next i
    Call putInfo(where, counter)
    End If
Next z
End Sub
Sub putInfo(where As String, info As Integer)
Dim s As Shape
Dim ws As Worksheet
Set ws = ActiveSheet
Set s = ws.Shapes.AddShape(msoShapeRectangle, 10, 10, 10, 10)
With s
    .Fill.ForeColor.RGB = RGB(255, 255, 255)
    .TextFrame2.VerticalAnchor = msoAnchorMiddle
    .TextFrame2.TextRange.ParagraphFormat.Alignment = msoAlignCenter
    .TextFrame2.TextRange.Font.Size = 20
    .TextFrame.Characters.Text = "" & info
    .TextFrame.Characters.Font.Color = RGB(0, 0, 0)
    .Top = Range(where).Top + (Range(where).Height / 2)
    .Left = Range(where).Left + (Range(where).Width / 2)
    .Width = Range(where).Width
    .Height = Range(where).Height * (info - 1)
End With
End Sub
Capture.PNG
 
Upvote 0

Forum statistics

Threads
1,214,909
Messages
6,122,189
Members
449,072
Latest member
DW Draft

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