Delete Entire row by vba (macro Correction)

addfg
Banned
Posts: 2
Joined: 18 Sep 2020, 17:21

Delete Entire row by vba (macro Correction)

Post by addfg »

Hi,

Code: Select all

Sub STEP9()
Dim wb As Workbook, wk As Workbook
Set wb = Workbooks.Open("C:\Users\**I've been banned**\Desktop\1.xls")
Set wk = Workbooks.Open("C:\Users\**I've been banned**\Desktop\HotStocks\H3.xlsb")
wb.Activate
lrow = wb.Sheets(1).Cells(Rows.Count, 1).End(xlUp).Row

lrow1 = wk.Sheets(2).Cells(Rows.Count, 1).End(xlUp).Row

For i = 2 To lrow1
    For j = 2 To lrow
        If wb.Sheets(1).Range("B" & j).Value = wk.Sheets(2).Range("A" & i).Value Then
        wb.Sheets(1).Range("i" & j).EntireRow.Delete
        End If
    Next
Next

wb.Close SaveChanges:=True
wk.Close SaveChanges:=True


End Sub



This macro is not working u corrected this macro but it has issue
If column B of 1.xls matches with column A of H3.xlsb then do nothing else delete entire row
we have to match each cells of column B & Column A


Thnx
You do not have the required permissions to view the files attached to this post.

User avatar
Leif
Administrator
Posts: 7193
Joined: 15 Jan 2010, 22:52
Location: Middle of England

Re: Delete Entire row by vba (macro Correction)

Post by Leif »

Is that you again, Avinash?
Leif

addfg
Banned
Posts: 2
Joined: 18 Sep 2020, 17:21

Re: Delete Entire row by vba (macro Correction)

Post by addfg »

Yes Avinash
https://www.excelforum.com/excel-progra ... ction.html
I thought u will again ban my account so for the backup I posted the question to below forum
https://www.excelforum.com/excel-progra ... ction.html