Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-02-2018, 08:54 AM
beefcake2000 beefcake2000 is offline Worksheet_Change VLookup issue when deleting rows (#N/A in every column) Windows 7 64bit Worksheet_Change VLookup issue when deleting rows (#N/A in every column) Office 2010 64bit
Novice
Worksheet_Change VLookup issue when deleting rows (#N/A in every column)
 
Join Date: Nov 2017
Posts: 10
beefcake2000 is on a distinguished road
Default 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.
Reply With Quote
 



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
Worksheet_Change VLookup issue when deleting rows (#N/A in every column) Deleting rows with specific criteria joflow21 Excel 9 11-22-2013 12:10 PM
Worksheet_Change VLookup issue when deleting rows (#N/A in every column) Excel VBA: Worksheet_Change Cells.Protect tinfanide Excel Programming 8 04-08-2012 09:58 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:05 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft