Look through a list in one workbook and then find the value in another list in another workbook then delete the row

HEzim

New Member
Joined
Mar 4, 2021
Messages
12
Office Version
  1. 365
  2. 2013
  3. 2011
Platform
  1. Windows
Hi I am new to VBA and beyond frustrated,


I have list A in a workbook A in Sheet A. And I have a list B in wookbook A in sheet B.

I need to run VBA so that It opens up a separate workbook X (only has 1 sheet), looks through the list in list A and finds the corresponding characters from list A in the workbook X then deletes the row it is found in.

And then again for List B, It is going to open a separate wookbook Y (only has 1 sheet), looks through list in List B and finds the corresponding character from list B in the workbook Y then deletes the row it is found in.

I have gotten this far but for whatever reason I keep getting an error message:

Sub Remover()


Dim Uid As Long, Lid As Long, U As Range, L As Range

Dim Uwbk As Workbook, Lwbk As Workbook
Dim Ws As Worksheet, Uws As Worksheet, Lws As Worksheet, UxWs As Worksheet, LxWs As Worksheet

Set Uws = ThisWorkbook.Sheets("List A")
Set Lws = ThisWorkbook.Sheets("List B")
Set Uwbk = Workbooks.Open("WorkbookX.csv")
Set Lwbk = Workbooks.Open("WorkbookY.csv")
Set UxWs = Uwbk.Worksheets("Sheet 1")
Set LxWs = Lwbk.Worksheets("Sheet 1")


For Uid = UxWs.Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
Set U = Uws.Columns("A").Find(UxWs.Cells(i, 1).Value)
If Not U Is Nothing Then Rows(i).Delete
Next

For Lid = LxWs.Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
Set L = Lws.Columns("A").Find(LxWs.Cells(i, 1).Value)
If Not L Is Nothing Then Rows(i).Delete
Next


End Sub

This doesn't work.
Can someone please help me out here?

Thank you,
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

HEzim

New Member
Joined
Mar 4, 2021
Messages
12
Office Version
  1. 365
  2. 2013
  3. 2011
Platform
  1. Windows
Just an FYI, where I say workbookx.csv or workbooky.csv there is actual directory that would open the file.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,659
Messages
5,637,622
Members
416,977
Latest member
kdoederlein

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
Top