I am trying to delete record but getting error while clicking on cell .
Code added on Sheet2:
On Sheet3 I have code
When I click on Sheet2 on specific cell there is error. Error 1004 " Method Intersect of Object Global Failed"
Any solution ?
Code added on Sheet2:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(ActiveCell, Range("q:q")) Is Nothing Then
If ActiveCell.Value = "Add to Orders List" Then
rowNum = Target.Cells.Row
cellval = WorksheetFunction.Sum(Sheet2.Range("E" & rowNum + 3 & ":O" & rowNum + 3))
If cellval = 0 Then
MsgBox "Please Add Number of Order/s (Yellow Cells)", vbInformation, "Input Required"
Sheet2.Range("E" & rowNum + 3 & ":O" & rowNum + 3).Select
Else
id = Range("A" & rowNum).Value
Set FindRow = Sheet3.Range("A:A").Find(What:=id, LookIn:=xlValues, LookAt:=xlWhole) 'Searching for Combobox1 value
If Not (FindRow Is Nothing) Then
'checking if same product is already added
MsgBox "Already Added"
Else
lastRow = Sheet3.Range("A10000").End(xlUp).Row 'Getting last row in orders sheet
If lastRow < 3 Then
Sheet2.Range(rowNum & ":" & rowNum + 4).Copy Sheet3.Range("A" & lastRow + 2)
Sheet3.Range("Q" & lastRow + 2).Value = "DELETE"
Sheet2.Range("O" & rowNum + 1).Select
ElseIf lastRow >= 3 Then
Sheet2.Range(rowNum & ":" & rowNum + 4).Copy Sheet3.Range("A" & lastRow + 6)
Sheet3.Range("Q" & lastRow + 6).Value = "DELETE"
Sheet2.Range("q" & rowNum + 1).Select
End If
End If
End If
End If
End If
End Sub
On Sheet3 I have code
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(ActiveCell, Range("Q:Q")) Is Nothing Then
If ActiveCell = "DELETE" Then
MsgBox "Delete is clicked"
End If
End If
End Sub
When I click on Sheet2 on specific cell there is error. Error 1004 " Method Intersect of Object Global Failed"
Any solution ?