Private Sub CommandButton1_Click()
Application.ScreenUpdating = False
Sheets("items_out").Activate
If TextBox1.Value <> "" And TextBox2.Value <> "" Then
lrow = WorksheetFunction.CountIf(Range("b6:b1000"), TextBox1.Value)
If lrow >= 1 Then
MsgBox ("عفواً هذا الكود تم إدخاله مسبقاً")
TextBox1.Value = ""
TextBox2.Value = ""
TextBox6.Value = ""
TextBox7.Value = ""
TextBox8.Value = ""
TextBox34.Value = ""
TextBox20.Value = ""
TextBox21.Value = ""
TextBox30.Value = ""
TextBox31.Value = ""
TextBox32.Value = ""
TextBox25.Value = ""
TextBox37.Value = ""
TextBox38.Value = ""
Else
lrow = Range("a" & Rows.Count).End(xlUp).Row
Range("A" & lrow + 1).Value = "=ROW()-5"
Range("b" & lrow + 1).Offset(0, 0).Value = TextBox1.Value
Range("b" & lrow + 1).Offset(0, 1).Value = TextBox8.Value
Range("b" & lrow + 1).Offset(0, 6).Value = TextBox2.Value
Range("b" & lrow + 1).Offset(0, 4).Value = TextBox37.Value
Range("b" & lrow + 1).Offset(0, 5).Value = TextBox30.Value
Range("b" & lrow + 1).Offset(0, 7).Value = TextBox38.Value
Range("b" & lrow + 1).Offset(0, 8).Value = TextBox6.Value
Range("b" & lrow + 1).Offset(0, 2).Value = Format(TextBox7.Value, "yyyy/mm/dd")
Range("b" & lrow + 1).Offset(0, 3).Value = TextBox40.Value
Range("c4").Value = Format(TextBox7.Value, "yyyy/mm/dd ddd")
Range("J4").Value = TextBox40.Value
TextBox1.Value = ""
TextBox2.Value = ""
TextBox6.Value = ""
TextBox8.Value = ""
TextBox34.Value = ""
TextBox30.Value = ""
TextBox31.Value = ""
TextBox32.Value = ""
TextBox37.Value = ""
TextBox38.Value = ""
End If
Else
MsgBox ("عفواً البيانات غير موجوده برجاء كتابة البيانات")
End If
Application.ScreenUpdating = True
TextBox1.SetFocus
End Sub
كود حضرتك لحل المشكلة هو
Sub Sum_Colom()
Dim ws As Worksheet, lr As Long
Set ws = ThisWorkbook.Worksheets("items_out")
lr = ws.Cells(Rows.Count, 1).End(xlUp).Row + 1
With ws.Range("A" & lr).Resize(1, 10)
.Interior.Color = vbYellow
.Borders.Value = 1
End With
ws.Range("C" & lr).Value = "الإجمالي"
ws.Range("H" & lr).Resize(, 2).Formula = "=SUM(H6:H11)"
End Sub