hello
I have this macro works very well when I write specific names it will add oval shape for entire row contains items or values for each name and it will count the oval shape into column N based on column M for each name , but I have to write them manually to count them . so what I want justl little adjusting for the code . should show the names in column M automatically when run the macro . and should replace the data when show the names or count them every time run the macro.
I have this macro works very well when I write specific names it will add oval shape for entire row contains items or values for each name and it will count the oval shape into column N based on column M for each name , but I have to write them manually to count them . so what I want justl little adjusting for the code . should show the names in column M automatically when run the macro . and should replace the data when show the names or count them every time run the macro.
VBA Code:
Public Sub AddRedOva3()
Dim Shp As Shape
Dim rg As Range, c As Range, fnd As Range, tRow As Long
Dim Value As Variant, t() As String
Application.ScreenUpdating = False
For Each Shp In ActiveSheet.Shapes
If Shp.Name <> "Button 1" Then Shp.Delete
Next Shp
For Each c In Range("N2:N" & Cells(Rows.Count, "N").End(xlUp).Row)
c = 0
Next c
Application.ScreenUpdating = True
Value = InputBox("Enter Value:", "Input")
t = Split(Value, ",")
lastrow = Range("B" & Rows.Count).End(xlUp).Row
Set rg = Sheets("sheet1").Range("B2:J" & lastrow)
For i = 0 To UBound(t)
invalue = t(i)
GoSub update_Counter
For r = 1 To lastrow
If rg(r, 1) <> "" And rg(r, 1) = invalue Then
For col = 1 To 9
Set c = rg(r, col)
If c <> "" Then
Set Shp = ActiveSheet.Shapes.AddShape(msoShapeOval, c.Left, c.Top, c.Width, c.Height)
Shp.Fill.Transparency = 1
Shp.Line.ForeColor.RGB = RGB(255, 0, 0)
Shp.Line.Weight = 1
If tRow > 0 Then Cells(tRow, "N") = Cells(tRow, "N") + 1
End If
Next col
End If
Next r
Next i
Exit Sub
update_Counter:
With Range("M:M")
Set fnd = .Find(What:=invalue, LookIn:=xlValues, Lookat:=xlWhole)
If Not fnd Is Nothing Then
tRow = fnd.Row
Else
End If
End With
Return
End Sub