اذهب الي المحتوي
أوفيسنا

دوائر حمراء


الردود الموصى بها

Try this modification

Option Explicit

Sub Draw_Circles()
    Const nMax As Integer = 30
    Dim mx, ws As Worksheet, v As Shape, x As Integer, r As Long, c As Long, cnt As Long
    Call Remove_Circles
    x = ActiveWindow.Zoom
    Application.ScreenUpdating = False
    Set ws = ThisWorkbook.Worksheets("ty")
    ActiveWindow.Zoom = 100
    mx = ws.Range("N2").Value
    If mx = 0 Or Not IsNumeric(mx) Then MsgBox "Enter Valid Number In Cell N2", vbExclamation: GoTo Skipper
    For c = 10 To 8 Step -1
        For r = 4 To 14 Step 2
            With ws.Cells(r, c)
                If .Value <> "" Then
                    cnt = cnt + 1
                    Set v = .Parent.Shapes.AddShape(msoShapeOval, .Left + 1, .Top + 1, .Width - 2, .Height - 2)
                    v.Fill.Visible = msoFalse
                    v.Line.ForeColor.SchemeColor = 10
                    v.Line.Weight = 1
                    If cnt = mx Then Exit For
                End If
            End With
        Next r
        If cnt = mx Then Exit For
    Next c
    cnt = 0
    For c = 2 To 10
        For r = 20 To 30 Step 2
            With ws.Cells(r, c)
                If .Value <> "" Then
                    cnt = cnt + 1
                    Set v = .Parent.Shapes.AddShape(msoShapeOval, .Left + 1, .Top + 1, .Width - 2, .Height - 2)
                    v.Fill.Visible = msoFalse
                    v.Line.ForeColor.SchemeColor = 10
                    v.Line.Weight = 1
                    If cnt = nMax Then Exit For
                End If
            End With
        Next r
        If cnt = nMax Then Exit For
    Next c
Skipper:
    ActiveWindow.Zoom = x
    Application.ScreenUpdating = True
    MsgBox "Done...", 64
End Sub

Sub Remove_Circles()
    Dim shp As Shape
    For Each shp In ActiveSheet.Shapes
        If shp.AutoShapeType = msoShapeOval Then shp.Delete
    Next shp
End Sub

 

  • Like 1
رابط هذا التعليق
شارك

مشكور استاذنا العزيز قلب الاسد

لكن المطلوب الكود يعمل على جدول واحد فقط اي يضع الدوائر في جدول واحد فقط من بداية يوم الاحد حتى يوم الخميس ولو امكن يكون الدوائر لو كان المطلوب 9 دوائر الاحد 2 الاثنين 2 الثلاثاء 2 الاربعاء 2 الخميس 1 وهكذا ايا كان العدد المطلوب واسف على كثرة الطلبات ولكن عشمنا كبير والله يعنكم ويصبركم علينا

رابط هذا التعليق
شارك

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

زائر
اضف رد علي هذا الموضوع....

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • تصفح هذا الموضوع مؤخراً   0 اعضاء متواجدين الان

    • لايوجد اعضاء مسجلون يتصفحون هذه الصفحه
×
×
  • اضف...

Important Information