VBA code help

Status
Not open for further replies.

strongman86

Board Regular
Joined
Feb 15, 2017
Messages
97
Lads,

This post relates to my previous one as no one is replying :)

https://www.mrexcel.com/forum/excel-questions/1054040-vba-runtime-error.html

I need to amend code so row is added. At the moment code only removes row. Million thanks.


Sub test()
Dim cnt, rw As Integer
Dim val As Variant




cnt = Worksheets("Data").Range("B20000").End(xlUp).Row
On Error Resume Next




For rw = cnt To 2 Step -1
val = Empty
val = Application.WorksheetFunction.VLookup(Worksheets("Data").Range("B" & rw).Value, Worksheets("MdProductDataList").Range("B:B"), 1, False)
If val = Empty Then
Worksheets("Data").Rows(rw).Delete
End If
nxt:
Next rw
End Sub
 

Some videos you may like

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,494
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Please don't duplicate threads. You can bump your original (once per day). This thread is closed.
 
Status
Not open for further replies.

Watch MrExcel Video

Forum statistics

Threads
1,108,675
Messages
5,524,220
Members
409,565
Latest member
Suilenroc

This Week's Hot Topics

Top