Delete entire row

L

Legacy 451409

Guest
I will place the vba code in sanju.xlsm

my all files are located in same place

Sheet name can be anything in both the files

Open the file and

If cells of column C of sanju.csv matches with sheet2 cells of column C of sanju.xlsx then delete that complete row

close and save the file
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Code:
Option Explicit


Sub Andy()
    Dim s1 As Worksheet, s2 As Worksheet
    Set s1 = Sheets("Sheet1")
    Set s2 = Sheets("Sheet2")
    Dim i As Long, j As Long, lr As Long, lr2 As Long
    lr = s1.Range("C" & Rows.Count).End(xlUp).Row
    lr2 = s2.Range("C" & Rows.Count).End(xlUp).Row
    Application.ScreenUpdating = False
    For i = lr To 1 Step -1
        For j = 1 To lr2
            If s1.Range("C" & i) = s2.Range("C" & j) Then
                s1.Range("C" & i).EntireRow.Delete
            End If
        Next j
    Next i
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    MsgBox "complete"


End Sub
 
Upvote 0
Thnx Alansidman Sirfor giving ur Precious Time and Great suport to this post
Have a Great Day Sir
 
Upvote 0
Code:
Option Explicit

Sub Mysub()
 
   Dim wbk1 As Workbook, wbk2 As Workbook
   Dim wsh1 As Worksheet, wsh2 As Worksheet
   Set wbk1 = Workbooks.Open(ThisWorkbook.Path & "\1.xls")
   Set wsh1 = wbk1.Worksheets(1)
   Set wbk2 = Workbooks.Open(ThisWorkbook.Path & "\BasketOrder..csv")
   Set wsh2 = wbk2.Worksheets(1)
   Dim i As Long, j As Long, lr As Long, lr2 As Long
   lr = wsh1.Range("B" & Rows.Count).End(xlUp).Row
   lr2 = wsh2.Range("C" & Rows.Count).End(xlUp).Row
   Application.ScreenUpdating = False
   For i = lr To 1 Step -1
       For j = 1 To lr2
           If wsh1.Range("B" & i) = wsh2.Range("C" & j) Then
                wsh1.Range("B" & i).EntireRow.Delete
            End If
        Next j
    Next i
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
 


End Sub


Plz see my question
i tried to modify the same code but i am getting error plz have a relook Sir
and i will run the macro from a seperate file so plz provide code according to the same
 
Upvote 0
I will place the vba code in sanju.xlsm

my all files are located in same place

Sheet name can be anything in both the files

Open the file and

If cells of column C of sanju.csv matches with column B of sanju.xlsx then delete the matched entire row of sanju.xlsx

and after the process close and save the file so that changes should be saved
 
Upvote 0
Where is the error and what is the error message. We are not mindreaders here. When you get the error, click on debug and tell us the pertinent information. Your code does not show sanju as a workbook. Please be consistent within your code and your ask. When they are not consistent, it is a guessing game. I don't like to guess.
 
Upvote 0
Sorry Sir But I have mentioned in my first post that file has to be open by vba but u have not considered the same in the vba code
now leave that Sir
the problem is
I will place the vba code in sanju.xlsm

my all files are located in same place
Sheet name can be anything in both the files
Open the file and
If cells of column C of sanju.csv matches with column B of sanju.xlsx then delete the matched entire row of sanju.xlsx
and after the process close and save the file so that changes should be saved
Plz have a relook Sir and consider all this thing in the vba code

 
Upvote 0
You have not responded to my questions about error messages. No answer means no help. Help us to help you by responding directly to our questions surrounding your problems. BTW, no where in post 1 do you specify that the VBA must open your file. Additionally, in post one, there is mention of only one file. Please be consistent in your request for assistance. You have only repeated in your latest post what you have stated earlier. This is not helpful.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,708
Messages
6,174,005
Members
452,542
Latest member
Bricklin

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
Back
Top