Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vba code check

Status
Not open for further replies.

rider1234

Programmer
Jun 21, 2019
51
IN
I have file file name is macro1.xlsm
i have a second file file name is 1.xls
i will add the macro in macro.xlsm
my first row contains headers in 1.xls file
If column D of 1.xls file matches with column H of 1.xls file then delete that complete row and save the changes and close the file

This is my problem
Code:
Sub Del()
Dim wbk1 As Workbook
Dim wsh1 As Worksheet
Dim rg As Range
Dim i As Long

Application.ScreenUpdating = False

Set wbk1 = Workbooks.Open(ThisWorkbook.Path & "\1.xls")
Set wsh1 = wbk1.Worksheets(1)
        
    Set rg = wsh1.Range(wsh1.Cells(wsh1.Rows.Count, "D").End(xlUp), wsh1.Cells(2, "D"))
    For i = rg.Cells.Count To 1 Step -1
        If rg(i).Value = rg(i).Offset(0, 4).Value Then rg(i).EntireRow.Delete
    Next i
    Application.DisplayAlerts = False
    wbk1.Close SaveChanges:=True
    Application.DisplayAlerts = True
    
End Sub


plz see the problem and code and let me know does my vba code contains error
 
Hi,

What is the problem? Please explain in specific detail.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
AD1D550E-FCB5-4AB6-A3C8-1F86CACE2554_ne1bcz.jpg
 
i dont have any problem
plz see the problem and check my code
is it perfect
i sented u only for a guidance that this is perfect bcoz i writed the code of some copying and some editing
 
Well, the way that anybody doing programming might do it is by following this simple process. Step 6 is how you test/verify your program.

1) define you requirements clearly, concisely an completely by writing it down.
2) review your requirements for logical and functional consistency.
3) write a test plan, defining data inputs and expected data outputs.
4) write your code in accordance with your requirements, using best and accepted coding standards.
5) review your code for logical and functional consistency.
6) run your data against your test plan and verify that it performs in accordance with your test plan expectations
7) congratulations! You have a working program.

BTW, you seem to have learned a lot in just a short time. Your coding looks very good. I expect that it will test well.

Skip,
[sub]
[glasses]Just traded in my OLD subtlety...
for a NUance![tongue][/sub]
"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein
AD1D550E-FCB5-4AB6-A3C8-1F86CACE2554_ne1bcz.jpg
 
I have no idea what you are trying to do.[ ] But you turn screen updating off at the start so you probably ought to turn it back on at the end.
 
Thnx SkipVought Sir and Deniall Sir for giving ur precious time and great guidance to this post
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top