اذهب الي المحتوي
أوفيسنا
بحث مخصص من جوجل فى أوفيسنا
Custom Search

محمد هشام.

الخبراء
  • Posts

    1,589
  • تاريخ الانضمام

  • تاريخ اخر زياره

  • Days Won

    126

محمد هشام. last won the day on ديسمبر 19

محمد هشام. had the most liked content!

السمعه بالموقع

2,229 Excellent

عن العضو محمد هشام.

  • تاريخ الميلاد 23 يون, 1986

البيانات الشخصية

  • Gender (Ar)
    ذكر
  • Job Title
    السلام عليكم
  • البلد
    المغرب
  • الإهتمامات
    تكنولوجيا

اخر الزوار

10,683 زياره للملف الشخصي
  1. وعليكم السلام ورحمة الله تعالى وبركاته جرب هدا Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim n As Range, f As String, count As Integer, i As Integer If Not Intersect(Target, Me.Range("A1:B2")) Is Nothing Then Dim WS As Worksheet: Set WS = Sheets("data") Dim xRow As Range: Set xRow = WS.Range("A1:J1") Dim tmp As Integer: tmp = xRow.Column xRow.ClearContents For Each n In Me.Range("A1:A2") If n.Value <> "" Then f = n.Value count = n.Offset(0, 1).Value For i = 1 To count If tmp > xRow.Columns.count + xRow.Column - 1 Then Exit Sub WS.Cells(xRow.Row, tmp).Value = f tmp = tmp + 1 Next i End If Next n End If End Sub test2.xlsb
  2. وعليكم السلام ورحمة الله تعالى وبركاته Sub MergeTotal() Dim WS As Worksheet, crWS As Worksheet, LastRow As Long, Irow As Long On Error Resume Next Set crWS = Sheets("total") On Error GoTo 0 If crWS Is Nothing Then MsgBox " غير موجودة total ورقة ", vbInformation Exit Sub Else Application.ScreenUpdating = False crWS.Range("A2:O" & crWS.Rows.Count).Clear End If Irow = 2 For Each WS In ThisWorkbook.Sheets If WS.Name <> crWS.Name Then LastRow = WS.Cells(WS.Rows.Count, 1).End(xlUp).Row If LastRow >= 2 Then WS.Range("A2:O" & LastRow).Copy crWS.Cells(Irow, 1).PasteSpecial Paste:=xlPasteAllUsingSourceTheme Irow = crWS.Cells(crWS.Rows.Count, 1).End(xlUp).Row + 1 End If End If Next WS Application.CutCopyMode = False Application.ScreenUpdating = True End Sub or Sub MergeTotal() Dim WS As Worksheet, Src As Worksheet Dim OnRng As Variant, rng As Range, r As Range Dim lastRow As Long, tmp As Long, col As Integer Set WS = Sheets("total") Application.ScreenUpdating = False lastRow = WS.Cells(WS.Rows.Count, "A").End(xlUp).Row If lastRow > 1 Then: WS.Rows("2:" & lastRow).Clear tmp = WS.Cells(WS.Rows.Count, "A").End(xlUp).Row + 1 For Each Src In ThisWorkbook.Sheets If Src.Name <> WS.Name Then OnRng = Src.Range("A2:O" & Src.Cells(Src.Rows.Count, "A").End(xlUp).Row).Value WS.Cells(tmp, 1).Resize(UBound(OnRng, 1), UBound(OnRng, 2)).Value = OnRng For lastRow = 1 To Src.Cells(Src.Rows.Count, "A").End(xlUp).Row WS.Rows(tmp + lastRow - 1).RowHeight = 18.5 Next lastRow tmp = WS.Cells(WS.Rows.Count, "A").End(xlUp).Row + 1 End If Next Src With WS.Range("A1:O" & WS.Cells(WS.Rows.Count, "A").End(xlUp).Row) .Borders.LineStyle = xlContinuous: .HorizontalAlignment = xlCenter: .VerticalAlignment = xlCenter End With Application.ScreenUpdating = True End Sub الرواتب.xlsb
  3. وعليكم السلام ورحمة الله تعالى وبركاته بعد إذن الأستاد @عبدالله بشير عبدالله بما ان الكود الخاص به يعتمد على التنسيق إليك حل آخر باظهار رسالة تنبيه عند تجاوز الحد الاقصى للتكرارات بشرط التاريخ في عمود b [نفس الشهر ] واسم المهنة عمود d والحالة في عمود F طريقة الإدخال الكود_ المهنة _الحالة Private Sub Worksheet_Change(ByVal Target As Range) Dim lastRow As Long, Max As Integer, kay As Variant, xdate As Variant Max = 5 Application.EnableEvents = False lastRow = Cells(Rows.Count, 4).End(xlUp).Row If Not Intersect(Target, Me.Columns("B")) Is Nothing Then For Each cell In Target If cell.Value <> "" And IsEmpty(cell.Offset(0, 1).Value) Then cell.Offset(0, 1).Value = Date Else cell.Offset(0, 1).Value = "" End If Next cell End If If Not Intersect(Target, Me.Range("C5:F" & lastRow)) Is Nothing Then For Each cell In Target If cell.Column = 6 And cell.Value = "إجازة" Then kay = cell.Offset(0, -2).Value xdate = cell.Offset(0, -3).Value If IsEmpty(kay) Or IsEmpty(xdate) Then MsgBox "يجب إدخال كود الموظف", vbExclamation, "إنتبـــــاه" cell.ClearContents GoTo SupAPP End If If WorksheetFunction.CountIfs(Range("D5:D" & _ lastRow), kay, Range("F5:F" & lastRow), "إجازة", Range("C5:C" & lastRow), xdate) > 1 Then cell.ClearContents MsgBox " تم الوصول للحد الأقصى للإجازات هدا الشهر لسائقين :" & _ " " & kay, vbExclamation, "إنتبـــــاه" GoTo SupAPP End If If WorksheetFunction.CountIfs(Range("D5:D" & _ lastRow), kay, Range("F5:F" & lastRow), "إجازة", Range("C5:C" & lastRow), ">=" & WorksheetFunction.EoMonth(xdate, -1) + 1, _ Range("C5:C" & lastRow), "<=" & WorksheetFunction.EoMonth(xdate, 0)) > Max Then cell.ClearContents MsgBox "وصلت للحد الأقصى لهذا الشهر في إجازات السائق: " & kay, vbExclamation, "إنتبـــــاه" End If End If SupAPP: Next cell End If Application.EnableEvents = True End Sub اجاز V1.xlsb
  4. وعليكم السلام ورحمة الله تعالى وبركاته بعد إدن الأستاد @عبدالله بشير عبدالله إليك حلول أخرى =IF(A1>3000, A1*IF(B1<=500, 1.5, 2.5), IF(B1<500, 6000, "")) =IFERROR(IFS( AND(A1>3000, B1<=500), A1*1.5, AND(A1>3000, B1>500), A1*2.5, AND(A1<=3000, B1<500), 6000, TRUE, "" ), "") او Private Sub Worksheet_Change(ByVal Target As Range) If Not Intersect(Target, Me.Range("A:B")) Is Nothing Then Dim data As Variant, tmp() As Variant, lastRow As Long, i As Long Dim a As Double: a = 3000: b = 500: c = 6000 lastRow = Me.Cells(Me.Rows.Count, "A").End(xlUp).Row data = Me.Range("A1:B" & lastRow).Value ReDim tmp(1 To UBound(data, 1), 1 To 1) For i = 1 To UBound(data, 1) If IsEmpty(data(i, 1)) Or IsEmpty(data(i, 2)) Then tmp(i, 1) = "" ElseIf IsNumeric(data(i, 1)) And IsNumeric(data(i, 2)) Then If data(i, 1) > a Then tmp(i, 1) = IIf(data(i, 2) <= b, data(i, 1) * 1.5, data(i, 1) * 2.5) ElseIf data(i, 2) < b Then tmp(i, 1) = c Else tmp(i, 1) = "" End If Else tmp(i, 1) = "" End If Next i Me.Range("C1:C" & lastRow).Value = tmp End If End Sub test2025.xlsb
  5. وعليكم السلام ورحمة الله تعالى وبركاته ادا كان هدا ما تقصده جرب هدا =IFERROR(TEXT(DATE(2000+LEFT(B2,2),MID(B2,3,2),RIGHT(B2,2)),"DD/MM/YYYY"),"") او Option Explicit Sub ConvertDate() Dim lr As Long, r As Long, xDate As String, n As String Dim scWS As Worksheet: Set scWS = Sheets("Sheet1") lr = scWS.Cells(scWS.Rows.Count, "B").End(xlUp).Row For r = 2 To lr xDate = scWS.Cells(r, "B").Value If xDate <> "" Then n = Format(DateSerial(2000 + Left(xDate, 2), _ Mid(xDate, 3, 2), _ Right(xDate, 2)), "dd/mm/yyyy") scWS.Cells(r, "D").Value = n End If Next r End Sub New Microsoft Excel Worksheet.xlsx
  6. نعم اخي @hanykassem نظرا للمثال المرفق هناك بعض الإحتمالات الواردة في حالة كان هناك تكرار لنفس القيم كما هو موضح في الصورة أدناه Private Sub Worksheet_Change(ByVal Target As Range) Dim WS As Worksheet: Set WS = Sheets("Sheet1") Dim i As Long, ling As Long, lastRow As Long, tmp As String, kayB As String, kayC As String, _ j As Variant, a As Object, r As Object Set a = CreateObject("Scripting.Dictionary"): Set r = CreateObject("Scripting.Dictionary") If Not Intersect(Target, WS.Range("A4:C" & WS.Rows.Count)) Is Nothing Then Application.ScreenUpdating = False With WS .Range("I3:K" & .Rows.Count).ClearContents lastRow = .Cells(.Rows.Count, "A").End(xlUp).Row ling = 3 For i = 4 To lastRow tmp = .Cells(i, 1).value kayB = .Cells(i, 2).value kayC = .Cells(i, 3).value If tmp <> "" Then If kayB <> "" Then a(tmp) = IIf(a.Exists(tmp), a(tmp) & " , " & kayB, kayB) If kayC <> "" Then r(tmp) = IIf(r.Exists(tmp), r(tmp) & " , " & kayC, kayC) End If Next i For Each j In a.Keys .Cells(ling, 9).value = j .Cells(ling, 10).value = a(j) .Cells(ling, 11).value = r(j) ling = ling + 1 Next j .Columns("j:K").AutoFit End With Application.ScreenUpdating = True End If End Sub لحدف التكرارات قم بتعديل الصف التالي If tmp <> "" Then If kayB <> "" Then a(tmp) = IIf(a.Exists(tmp), a(tmp) & " , " & kayB, kayB) If kayC <> "" Then r(tmp) = IIf(r.Exists(tmp), r(tmp) & " , " & kayC, kayC) End If إلى If tmp <> "" Then If kayB <> "" Then If Not a.Exists(tmp) Then a.Add tmp, _ kayB Else If InStr(1, a(tmp), kayB) = 0 Then a(tmp) = a(tmp) & " , " & kayB If kayC <> "" Then If Not r.Exists(tmp) Then r.Add tmp, _ kayC Else If InStr(1, r(tmp), kayC) = 0 Then r(tmp) = r(tmp) & " , " & kayC End If TEST CODE 2.xlsb
  7. يمكنك تعديل كود عرض الأعمدة بترتيب العناصر على الشكل التالي Private Sub ContrArr(tmp As Long) Dim controls As Variant, columns As Variant, i As Integer controls = Array("TextBox7", "ComboBox1", "ComboBox2", "ComboBox3", "ComboBox4", _ "TextBox3", "TextBox4", "TextBox5", "TextBox6", "ComboBox5") columns = Array(2, 4, 5, 6, 7, 8, 9, 10, 11, 12) If Me.TextBox8.Text = "" Then ClearControls Else Me.TextBox8.Tag = tmp For i = LBound(controls) To UBound(controls) Me.controls(controls(i)).Text = WS.Cells(tmp, columns(i)).Value Next i tblUpdate tmp End If End Sub البحث والتنقل.rar
  8. وعليكم السلام ورحمة الله تعالى وبركاته ربما هدا ما تقصده ادا كنت قد فهمت طلبك بشكل صحيح يمكنك حدف جميع الأكواد السابقة فهدا سيوفي بالغرض بعد إظافة عنصر Label جديد بإسم Label15 لإظهار عدد السجلات كما في الصورة المرفقة Public WS As Worksheet Private Sub UserForm_Initialize() Set WS = Sheets("تسجيل البيانات") End Sub Private Sub Navigation(r As Integer) Dim NInvoice As String, tmp As Long, Col As Long NInvoice = Trim(TextBox8.Text) If NInvoice = "" Then MsgBox "يرجى إدخال رقم الفاتورة", vbExclamation Exit Sub End If tmp = TextBox8.Tag Col = FndRow(NInvoice, tmp, r) If Col = 0 Then MsgBox TextBox8.Value & " : " & "لا يوجد سجلات " & IIf(r = 1, "لاحقة", "سابقة") & _ " بنفس رقم الفاتورة", vbExclamation Else ContrArr Col End If End Sub Private Function FndRow(facture As String, c As Long, r As Integer) As Long Dim tmp As Long, lastRow As Long lastRow = WS.Cells(WS.Rows.Count, 1).End(xlUp).Row If r = 1 Then For tmp = c + 1 To lastRow If WS.Cells(tmp, 1).Value = facture Then FndRow = tmp Exit Function End If Next tmp Else For tmp = c - 1 To 2 Step -1 If WS.Cells(tmp, 1).Value = facture Then FndRow = tmp Exit Function End If Next tmp End If FndRow = 0 End Function Private Sub ContrArr(tmp As Long) Dim n As Variant n = Array("TextBox7", "ComboBox1", "ComboBox2", "ComboBox3", "ComboBox4", _ "TextBox3", "TextBox4", "TextBox5", "TextBox6", "ComboBox5") If Me.TextBox8.Text = "" Then ClearControls Else Me.TextBox8.Tag = tmp For i = LBound(n) To UBound(n) Me.Controls(n(i)).Text = WS.Cells(tmp, i + 2).Value Next i tblUpdate tmp End If End Sub Private Sub SpinButton2_SpinDown() Navigation 1 End Sub Private Sub SpinButton2_SpinUp() Navigation -1 End Sub Private Sub résultats(facture As String) Dim Irow As Long Irow = ColRecherche(facture) If Irow = 0 Then MsgBox TextBox8.Value & " : " & "لا يوجد بيانات مطابقة لرقم الفاتورة", vbExclamation, "إنتـــباه" Me.TextBox8.Text = "" Label15.Caption = "السجل 1 من 1" Label15.Visible = False Else ContrArr Irow End If End Sub Private Function ColRecherche(facture As String) As Long Dim ColA As Range, cell As Range Set ColA = WS.Range("A2:A" & WS.Cells(WS.Rows.Count, 1).End(xlUp).Row) For Each cell In ColA If cell.Value = facture Then ColRecherche = cell.Row Exit Function End If Next cell ColRecherche = 0 End Function Private Sub ClearControls() Dim n As Variant n = Array("TextBox7", "ComboBox1", "ComboBox2", "ComboBox3", _ "ComboBox4", "TextBox3", "TextBox4", "TextBox5", "TextBox6", "ComboBox5") For i = LBound(n) To UBound(n) Me.Controls(n(i)).Text = "" Next i Me.TextBox8.Tag = "" Label15.Caption = "السجل 1 من 1" Label15.Visible = False End Sub Private Sub TextBox8_Change() If Me.TextBox8.Text = "" Then ClearControls Label15.Visible = False Exit Sub End If If Not IsNumeric(Me.TextBox8.Text) Then MsgBox "الرجاء إدخال قيمة رقمية فقط", vbExclamation Me.TextBox8.Text = "" ClearControls Exit Sub End If résultats Trim(TextBox8.Text) End Sub Private Sub tblUpdate(tblRow As Long) Dim facture As String, tblCount As Long, tmp As Long, lastRow As Long, tblMatch As Long facture = Trim(TextBox8.Text) lastRow = WS.Cells(WS.Rows.Count, 1).End(xlUp).Row tblMatch = 0: tblCount = 0 For tmp = 2 To lastRow If WS.Cells(tmp, 1).Value = facture Then tblCount = tblCount + 1 If tmp = tblRow Then tblMatch = tblCount End If End If Next tmp Label15.Caption = "السجل " & tblMatch & " من " & tblCount Label15.Visible = True End Sub لقد قمت برفع ملفين: الأول بدون إظهار عدد السجلات والثاني يقوم بإظهارها يمكنك اختيار ما يناسبك بالتوفيق........... البحث والتنقل.rar
  9. If Not Intersect(Target, Me.Range("I:L")) Is Nothing Then UnitsArr = Array("فدان", "قيراط", "سهم", "م²") With srcWS lastRow = .Columns("I:L").Find(What:="*", _ SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row If lastRow < 10 Then Exit Sub ColArr = .Range("I10:L" & lastRow).Value ReDim tmp(1 To lastRow - 9, 1 To 1) For i = 1 To UBound(ColArr, 1) tbl = "" For j = 4 To 1 Step -1 If IsNumeric(ColArr(i, j)) And ColArr(i, j) > 0 Then tbl = tbl & IIf(tbl <> "", " و ", "") & ColArr(i, j) & " " & UnitsArr(4 - j) End If Next j tmp(i, 1) = tbl Next i مساحة2.xlsb
  10. يكون أفضل لو أرفقت عينة لشكل البيانات المتوقع مع تحديد مكان وضعها هل في نفس مكان البيانات الأصلية أو في أعمدة مغايرة
  11. وعليكم السلام ورحمة الله تعالى وبركاته بإستخدام الأكواد يمكنك تجربة هدا Private Sub Worksheet_Change(ByVal Target As Range) On Error GoTo ExitApp Application.EnableEvents = False Dim tmp() As Variant, ColArr As Variant, lastRow As Long, _ UnitsArr As Variant, i As Long, j As Integer, tbl As String Dim srcWS As Worksheet: Set srcWS = Me If Not Intersect(Target, Me.Range("I:L")) Is Nothing Then UnitsArr = Array("م²", "سهم", "قيراط", "فدان") With srcWS lastRow = .Columns("I:L").Find(What:="*", _ SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row If lastRow < 10 Then Exit Sub ColArr = .Range("I10:L" & lastRow).Value ReDim tmp(1 To lastRow - 9, 1 To 1) For i = 1 To UBound(ColArr, 1) tbl = "" For j = 1 To 4 If IsNumeric(ColArr(i, j)) And ColArr(i, j) > 0 Then tbl = tbl & IIf(tbl <> "", " و ", "") & ColArr(i, j) & " " & UnitsArr(j - 1) End If Next j tmp(i, 1) = tbl Next i With .Range("M10:M" & lastRow) .Value = tmp .ReadingOrder = xlRTL End With End With End If ExitApp: Application.EnableEvents = True End Sub مساحة.xlsb
  12. For tmp = 6 To Irow If IsNumeric(SrcWS.Cells(tmp, "A").Value) Then SrcWS.Cells(tmp, "A").ClearContents End If Next tmp مطلوب ترقيم تلقائى لا يتأثر بحذف الصفوف.xlsb
  13. هل تقصد حساب عدد الخلايا التي تحتوي على خليط من نصوص وأرقام مثلا 1م3 او T5 جرب هدا Option Explicit Function CalculerVal(rng As Range) As Long Dim cnt As Range, tmp As Long tmp = 0 For Each cnt In rng If cnt.Value <> "" Then If IsNumeric(cnt.Value) Or cnt.Value Like "*[0-9]*" Then tmp = tmp + 1 End If End If Next cnt CalculerVal = tmp End Function في الخلية التي تريد أن تظهر فيها النتيجة مع تعديلها بما يتناسب مع بياناتك الأصلية =CalculerVal(B2:H2) مجموع الأرقام مع الحروف.xlsb
  14. وعليكم السلام ورحمة الله تعالى وبركاته جرب هدا Private Const Clé As String = "1234" ' قم بتعديل الباسوورد بما يناسبك Private Sub Worksheet_Change(ByVal Target As Range) Dim lastRow As Long lastRow = Cells(Rows.Count, "J").End(xlUp).Row ActiveSheet.Unprotect Clé If Not Intersect(Target, Me.Range("J7:J" & lastRow)) Is Nothing And Target.Columns.Count = 1 Then Application.EnableEvents = False Dim cell As Range For Each cell In Target If cell.Row >= 7 Then cell.Locked = Not IsEmpty(cell.Value) Next cell Application.EnableEvents = True End If ActiveSheet.Protect Clé, UserInterfaceOnly:=True End Sub '================================== Private Sub Worksheet_SelectionChange(ByVal Target As Range) Dim lastRow As Long, choose As String: Static OnRng As Range lastRow = Cells(Rows.Count, "J").End(xlUp).Row If Not Intersect(Target, Me.Range("J7:J" & lastRow)) Is Nothing Then If Not IsEmpty(Target.Value) Then If Target.Locked Then choose = InputBox(": خلية التوقيع محمية الرجاء إدخال كلمة المرور", ":إنتــباه") If choose = Clé Then ActiveSheet.Unprotect Clé If Not OnRng Is Nothing Then OnRng.Locked = True Target.Locked = False Set OnRng = Target ActiveSheet.Protect Clé, UserInterfaceOnly:=True ElseIf choose <> "" Then MsgBox "كلمة المرور غير صحيحة", vbExclamation, "خطأ" End If Else Set OnRng = Target End If Else ActiveSheet.Unprotect Clé Target.Locked = False Set OnRng = Nothing ActiveSheet.Protect Clé, UserInterfaceOnly:=True End If End If End Sub شيت حوافز تجريبى V2.xlsb
  15. ماذا تقصد بصفحات أخرى؟ هل أوراق عمل أخرى أو جداول جديدة في نفس الورقة ؟ اذا كنت تقصد جداول فهذا ما يفعله الكود عند إظافة جدول يتضمن نفس الشروط حاول تحديد و نسخ أي جدول بداية من صف عناوين الأعمدة إلى غاية صف المختص ونسخه أسفل الجداول السابقة ستلاحظ تحديث الترقيم تلقائيا
×
×
  • اضف...

Important Information