VBA code for changes in cell and delete cell value

cooleomter

New Member
Joined
Sep 3, 2024
Messages
25
Office Version
  1. 365
  2. 2021
Platform
  1. Windows
The COde works if i only delete one by one.. But if i Highlight many cells and delete all at once.. it debugs
Need help please,... here is my code:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim nextRow As Long
Set historyWks = ActiveSheet

'Check if the changed cells are in the specified range
If Not Intersect(Target, Me.Range("C8:C3000")) Is Nothing Then
' to check cell if empty. or i delete
If Target.Cells.Value = " " Or IsEmpty(Target) Then Exit Sub 'Check if target cell is empty

With historyWks
nextRow = .Cells(.Rows.Count, "C").End(xlUp).Offset(0, 1).Row
End With

With historyWks
With .Cells(nextRow, "G")
.Value = Date
.NumberFormat = "mm/dd/yyyy"
End With
With .Cells(nextRow, "F")
.Value = Time
.NumberFormat = "h:mm:ss AM/PM"
End With
With .Cells(nextRow, "D")
.Value = Range("F1").Value 'pACKING OPERATOR
End With
With .Cells(nextRow, "H")
.Value = Range("D2").Value ' MODEL
End With
With .Cells(nextRow, "I")
.Value = Range("F2").Value ' wEIGHING OPERATOR
End With

End With

End If


End Sub
 
You are welcome.
test4.xlsm
ABCDEFGHIJ
1Category:Packing OperatorShipment Plan Qty: 
2ModelWeighing OperatorFinished Good Qty.: 
3Shipment Date:Shipment FreightGood Weight 
4Start SerialEnd SerialNG Weight 
5Minimum Maximum Lacking 
6Excess 
7Box No. BIGBox No. SMALLWeightPacking OperatorSerial NumberTimeDateModelWeighing OperatorRemarks
8   
9   
10   
11   
12   
13   
14   
15   
16   
MASTER COPY
Cell Formulas
RangeFormula
D5D5=IF((D2=""),"",INDEX(Validation!I2:I8,MATCH('MASTER COPY'!D2,Validation!F2:F8,0)))
F5F5=IF((D2=""),"",INDEX(Validation!J2:J8,MATCH('MASTER COPY'!D2,Validation!F2:F8,0)))
H1H1=IF(D4="","",(F4-D4+1))
H2H2=COUNT(C8:C100384)
H3H3=H2-H4
H4H4=((COUNTIFS(C8:C100000,"<"&D5)+(COUNTIFS(C8:C100000,">"&F5))))
H5H5=((COUNTIFS(C8:C10001,"<"&D5)))
H6H6=((COUNTIFS(L8:L10003,">"&O5)))
A8:A16A8=IFERROR(IFS($D$2="HDROP-14",INDEX(Serial!$E$2:$E$25426,MATCH('MASTER COPY'!E8,Serial!$A$2:$A$25426,0)),$D$2="IND-B",INDEX(Serial!$D$2:$D$25426,MATCH('MASTER COPY'!E8,Serial!$A$2:$A$25426,0)),OR($D$2="HDROP-FK1",$D$2="JD2100",$D$2="JD2000WH",$D$2="JD2000BK"),INDEX(Serial!$B$2:$B$25426,MATCH('MASTER COPY'!E8,Serial!$A$2:$A$25426,0)),$D$2="ZR-02",INDEX(Serial!$F$2:$F$25426,MATCH('MASTER COPY'!E8,Serial!$A$2:$A$25426,0))),"")
B8:B16B8=IFERROR(IFS(OR($D$2="HDROP-14",$D$2="ZR-02"),INDEX(Serial!$C$2:$C$25426,MATCH('MASTER COPY'!E8,Serial!$A$2:$A$25426,0))),"")
E7E7=IF(OR(D1="Option",D1="Harness"),"Item Count","Serial Number")
E8E8=IF(C8="","",D4)
E9:E16E9=IF(C9="","",E8+1)
Named Ranges
NameRefers ToCells
ACCList=Validation!$F$6:$F$8D5, F5
OPList=Validation!$F$3:$F$5D5, F5
SIBList=Validation!$F$2D5, F5
Cells with Conditional Formatting
CellConditionCell FormatStop If True
C8:C1048576Cell Value<$D$5textNO
C8:C1048576Cell Value>$F$5textNO
Cells with Data Validation
CellAllowCriteria
D1List=ManuList
D2List=INDIRECT(VLOOKUP($D$1,ManuLookUp,2,0) &"List")
D3Any value
F1:F2List=OFFSET(Validation!$A$2:$A$999267,0,0,COUNTA(Validation!$A$2:$A$198)-0,1)
F3List=Validation!$C$10:$C$14
 
Upvote 0

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,224,743
Messages
6,180,687
Members
452,994
Latest member
Janick

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top