Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


vba code check

vba code check

vba code check

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

RE: vba code check


What is the problem? Please explain in specific detail.


glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: vba code check

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

RE: vba code check

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.


glassesJust traded in my OLD subtlety...
for a NUance!tongue

"The most incomprehensible thing about the universe is that it is comprehensible" A. Einstein

RE: vba code check

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.

RE: vba code check

Thnx SkipVought Sir and Deniall Sir for giving ur precious time and great guidance to this post

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close