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

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

قام بنشر

السلام وعليكم

اخوتي الكرام ممكن احد يساعدني في هذا الكود

Private Sub Worksheet_Change(ByVal Target As Range)

Dim note As Integer, score_comment As String

note = Range("A1")

If note = 6 Then

score_comment = "Excellent score !"

ElseIf note = 5 Then

score_comment = "Good score"

ElseIf note = 4 Then

score_comment = "Satisfactory score"

ElseIf note = 3 Then

score_comment = "Unsatisfactory score"

ElseIf note = 2 Then

score_comment = "Bad score"

ElseIf note = 1 Then

score_comment = "Terrible score"

Else: score_comment = "Zero score"

End If

Range("B1") = score_comment

End Sub

ما معنى المصطلح

ByVal

المطلوب هل بالامكان ان ينطبق الكود على العمود في نطاق الخلايا التالية

A2 to A100

والنتيجة تظهر في كامل العمود في النطاق التالي

B2 to B10

 

هناك ملف مرفق

وشكرا

Book1.rar

قام بنشر

السلام وعليكم

 

للفائدة تم وضع السؤال في احدى المنتديات الأجنبية http://www.excelforum.com/ وتم حلة وحبيت ان اشارككم الحل لتعم الفائدة:

تم الحل من قبل احد الاخوة اسمة dflak له جزيل الشكر

Option Explicit

Sub GradeIt()
Dim note As Integer             ' "Grade" from Column A
Dim score_comment As String     ' Interpretation of the grade
Dim i As Long                   ' Counter for rows

' Loop through rows 2 to 100
For i = 2 To 100
    note = Sheets("Sheet1").Cells(i, 1)
    ' Make comment based on the value of note
    Select Case note
        Case 6
            score_comment = "Excellent score !"
        Case 5
            score_comment = "Good score"
        Case 4
            score_comment = "Satisfactory score"
        Case 3
            score_comment = "Unsatisfactory score"
        Case 2
            score_comment = "Bad score"
        Case 1
            score_comment = "Terrible score"
        Case Else
            score_comment = "Zero score"
    End Select

    Sheets("Sheet1").Cells(i, 2) = score_comment
Next i

End Sub

 

 

 

 

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