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

طلب تصحيح كود


إذهب إلى أفضل إجابة Solved by أ / محمد صالح,

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

السلام عليكم 

اود من أساتذة المنتدى تصحيح بعض الأكواد

في الملف المرفق عملت نموذخ ادخال البيانات من الشيت SAISIE إلى شيت DATA ELV و عملت الاكواد لاضافة البيانات- البحث و الاستعلام - تعديل و حذف (منقولة عن بعض الاساتذة جزاهم الله كل خير) و لكن لا اعرف اين الخلل فيها 

ارجو المساعدة و شكرا 

Classeur1111.xlsm

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

  • أفضل إجابة

تفضل هذه إعادة صياغة اختصار للأكواد

حيث من قواعد البرمجة عدم كتابة الكود مرتين

تم عمل دالة لمسح المحتويات clr

ودالة للاضافة أو التعديل معا addedit بدلالة رقم الصف

Private Sub CommandButton1_Click()
Dim med As long
med = Sheets("DATA ELV").Range("b10000").End(xlUp).Row + 1
addedit med
clr
MsgBox "تم نقل البيانات", vbInformation, "تمت العملية بنجاح"
End Sub
Private Sub CommandButton2_Click()
clr
Sheets("DATA ELV").Range("y2").Value = Sheets("SAISIE").Range("c2").Value
If Not IsNumeric(Sheets("DATA ELV").Range("z2").Value) Then
MsgBox "هذا الاسم غير موجود"
Else
Dim a As long
a = Sheets("DATA ELV").Range("z2").Value
Sheets("SAISIE").Range("c4").Value = Sheets("DATA ELV").Cells(a, "c")
Sheets("SAISIE").Range("c6").Value = Sheets("DATA ELV").Cells(a, "d")
Sheets("SAISIE").Range("c8").Value = Sheets("DATA ELV").Cells(a, "e")
Sheets("SAISIE").Range("c10").Value = Sheets("DATA ELV").Cells(a, "f")
Sheets("SAISIE").Range("c12").Value = Sheets("DATA ELV").Cells(a, "g")
Sheets("SAISIE").Range("c14").Value = Sheets("DATA ELV").Cells(a, "h")
Sheets("SAISIE").Range("c16").Value = Sheets("DATA ELV").Cells(a, "i")
Sheets("SAISIE").Range("c18").Value = Sheets("DATA ELV").Cells(a, "j")
Sheets("SAISIE").Range("c20").Value = Sheets("DATA ELV").Cells(a, "k")
Sheets("SAISIE").Range("f4").Value = Sheets("DATA ELV").Cells(a, "l")
Sheets("SAISIE").Range("f6").Value = Sheets("DATA ELV").Cells(a, "m")
Sheets("SAISIE").Range("f8").Value = Sheets("DATA ELV").Cells(a, "n")
Sheets("SAISIE").Range("f10").Value = Sheets("DATA ELV").Cells(a, "o")
Sheets("SAISIE").Range("f12").Value = Sheets("DATA ELV").Cells(a, "p")
Sheets("SAISIE").Range("f14").Value = Sheets("DATA ELV").Cells(a, "q")
Sheets("SAISIE").Range("f16").Value = Sheets("DATA ELV").Cells(a, "r")
Sheets("SAISIE").Range("f18").Value = Sheets("DATA ELV").Cells(a, "s")
End If
End Sub

Private Sub CommandButton3_Click()
Sheets("DATA ELV").Range("y2").Value = Sheets("SAISIE").Range("c2").Value
Dim s As long
s = Sheets("DATA ELV").Range("z2").Value
addedit s
clr
MsgBox "تم تعديل البيانات", vbInformation, "تمت العملية بنجاح"
End Sub

Private Sub CommandButton4_Click()
Sheets("DATA ELV").Range("y2").Value = Sheets("SAISIE").Range("c2").Value
Dim r As long
r = Sheets("DATA ELV").Range("z2").Value
Sheets("DATA ELV").Rows(r).Delete
clr
MsgBox "تم حذف البيانات", vbInformation, "تمت العملية بنجاح"
End Sub

Sub clr()
Sheets("SAISIE").Range("c4").Value = ""
Sheets("SAISIE").Range("c6").Value = ""
Sheets("SAISIE").Range("c8").Value = ""
Sheets("SAISIE").Range("c10").Value = ""
Sheets("SAISIE").Range("c12").Value = ""
Sheets("SAISIE").Range("c14").Value = ""
Sheets("SAISIE").Range("c16").Value = ""
Sheets("SAISIE").Range("c18").Value = ""
Sheets("SAISIE").Range("c20").Value = ""
Sheets("SAISIE").Range("f4").Value = ""
Sheets("SAISIE").Range("f6").Value = ""
Sheets("SAISIE").Range("f8").Value = ""
Sheets("SAISIE").Range("f10").Value = ""
Sheets("SAISIE").Range("f12").Value = ""
Sheets("SAISIE").Range("f14").Value = ""
Sheets("SAISIE").Range("f16").Value = ""
Sheets("SAISIE").Range("f18").Value = ""
End Sub
Sub addedit(rw As Long)
Sheets("DATA ELV").Cells(rw, "c").Value = Sheets("SAISIE").Range("c4").Value
Sheets("DATA ELV").Cells(rw, "d").Value = Sheets("SAISIE").Range("c6").Value
Sheets("DATA ELV").Cells(rw, "e").Value = Sheets("SAISIE").Range("c8").Value
Sheets("DATA ELV").Cells(rw, "f").Value = Sheets("SAISIE").Range("c10").Value
Sheets("DATA ELV").Cells(rw, "g").Value = Sheets("SAISIE").Range("c12").Value
Sheets("DATA ELV").Cells(rw, "h").Value = Sheets("SAISIE").Range("c14").Value
Sheets("DATA ELV").Cells(rw, "i").Value = Sheets("SAISIE").Range("c16").Value
Sheets("DATA ELV").Cells(rw, "j").Value = Sheets("SAISIE").Range("c18").Value
Sheets("DATA ELV").Cells(rw, "k").Value = Sheets("SAISIE").Range("c20").Value
Sheets("DATA ELV").Cells(rw, "l").Value = Sheets("SAISIE").Range("f4").Value
Sheets("DATA ELV").Cells(rw, "m").Value = Sheets("SAISIE").Range("f6").Value
Sheets("DATA ELV").Cells(rw, "n").Value = Sheets("SAISIE").Range("f8").Value
Sheets("DATA ELV").Cells(rw, "o").Value = Sheets("SAISIE").Range("f10").Value
Sheets("DATA ELV").Cells(rw, "p").Value = Sheets("SAISIE").Range("f12").Value
Sheets("DATA ELV").Cells(rw, "q").Value = Sheets("SAISIE").Range("f14").Value
Sheets("DATA ELV").Cells(rw, "r").Value = Sheets("SAISIE").Range("f16").Value
Sheets("DATA ELV").Cells(rw, "s").Value = Sheets("SAISIE").Range("f18").Value
End Sub

المشكلة في كود البحث

كانت في عدم مراعاة ألا يكون الاسم موجودا

بالتوفيق

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

الحل في تغيير نوع البيانان Integer إلى long كما هو مستعمل في الاجراء addedit

Dim med As Long
&
Dim s As Long

في الزر الأول والثالث

تم تعديل الكود السابق

  • Like 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