• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

modify Transfer Code from Invoice Page to other pages without spaces (Blanks)

Hany ali

Active Member
Hello my Dear
i want your help in this Transfer Code ,it work well ..transfer from Invoice Page to Sales and Purchases Pages when i select from Cell D2 , but with blanks
I want to complete the migration process in succession without any blanks

Code:
Sub Transfer()
Dim fa, mb, mo As Worksheet
Dim lr1, lr2 As Integer
Set fa = Sheets("Invoice")
Set mb = Sheets("Sales")
Set mo = Sheets("Purchases")
If [I4].Value = "" Or [C3].Value = "" Or [d2].Value = "" Or [H3].Value = "" Then
MsgBox "Invoice Data Not Complete", vbCritical, "Warrning":
Else
Dim x As String
x = [d2].Value
fa.Activate
lr1 = fa.Range("B" & Rows.Count).End(xlUp).Row
Range("B6:L" & lr1).Copy
Sheets(x).Activate
lr2 = Range("B" & Rows.Count).End(xlUp).Row
Range("B" & lr2 + 1).Select
Selection.PasteSpecial xlPasteValues
fa.Activate
[d2].Select
Range("C6:E20").ClearContents
Range("G6:G20").ClearContents
Range("I6:I20").ClearContents
Range("D2:G2").ClearContents
Range("H3:J3").ClearContents
[C3].ClearContents
MsgBox ("Done")
End If
End Sub
 

Attachments

I may have misunderstood you, but it seems to me the best way to understand why your program is creating blanks is to learn to use the special debugging keys. Look in your VBA Editor under Debug; you'll see options such as "Step Into". A quick summary:

<F5> runs your program.

<F8> runs just the next statement in your program. It highlights the next statement, and you can hover your mouse over a variable to see what ts value is currently. Step through the program one statement at a time and you'll be able to see exactly what it's doing, which will help you figure out why it's not behaving the way you want it to.

You can experiment with the other options, learn what they do, and use them to debug your program. It's very helpful!
 
I can't tell what you mean. If you want me to help you, you must tell me what you did and what is the result. (It cannot be true that you didn't get any result; if you hit <F5> or <F8>, something happened, even if it isn't what you wanted to happen.) Tell me what you did, and what followed.
 
Top