#1
|
|||
|
|||
Worksheet_Change VLookup issue when deleting rows (#N/A in every column)
Hi guys,
I am using Worksheet_Change & VLookup to collect data from a sheet called 'groslijst' into a sheet called 'Wijzigingen'. I am using the following code: Private Sub Worksheet_Change(ByVal Target As Range) Application.ScreenUpdating = False Application.EnableEvents = False selectedNa = Target.Value If Target.Column = 1 Then selectedNum = Application.VLookup(selectedNa, Worksheets("Groslijst").Range("C4:N4000"), 12, False) If Not IsError(selectedNum) Then Target.Value = selectedNum End If End If Application.ScreenUpdating = True Application.EnableEvents = True End Sub This code works fine until I try to delete rows in the 'Wijzigen' sheet with the following code: Sub RowKiller() Dim LRow As Long Dim delRange As Range With ThisWorkbook.Sheets("Wijzigingen") .AutoFilterMode = False LRow = .Range("A" & .Rows.Count).End(xlUp).row With .Range("A1:A" & LRow) .AutoFilter Field:=1, Criteria1:="<>" Set delRange = .Offset(1, 0).SpecialCells(xlCellTypeVisible).EntireRow End With .AutoFilterMode = False End With If Not delRange Is Nothing Then delRange.Delete End Sub It returns a #N/A that I can't delete. I basically want to run a macro that copies the contents of wijzigingen to another sheet and then deletes all the processed data, leaving empty rows for furture data entry. I am quite new to VBA so I may have done something very foolish, but any help would be appreciated. |
#2
|
|||
|
|||
Can you upload a sample workbook?
Don't need 4000 rows of data, just enough to see what's going on, thanks. |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How can I return Vlookup only if Specific Criteria is met in 1 column of the Vlookup Array | EcommDOC | Excel | 7 | 01-22-2018 11:00 AM |
VBA - Deleting Rows (criteria based) | BobbyG | Project | 1 | 07-31-2017 08:55 AM |
If column A contains text, vlookup column H on the same row | scorpain | Excel | 8 | 11-11-2015 01:33 AM |
Deleting rows with specific criteria | joflow21 | Excel | 9 | 11-22-2013 12:10 PM |
Excel VBA: Worksheet_Change Cells.Protect | tinfanide | Excel Programming | 8 | 04-08-2012 09:58 PM |