Excel VBA Copy & Paste
B7,C7,D7 and E7 cells in Invoice sheet are copied into blank rows in the Data sheet.
Our VBA codes that we used in the template:
We used this code to find the first blank cell in column A and we assigned it to "son" variable :
Our VBA codes that we used in the template:
Private Sub CommandButton1_Click()
Dim son As Long
If Sheets("Invoice").Range("B7") = "" Or Sheets("Invoice").Range("C7") = "" Or _
Sheets("Invoice").Range("D7") = "" Or Sheets("Invoice").Range("E7") = "" Then MsgBox "Missing Data", _
vbCritical: Exit Sub
son = Sayfa1.Range("A" & Rows.Count).End(xlUp).Row
Sheets("Data").Cells(son + 1, 1) = Sheets("Invoice").Range("B7")
Sheets("Data").Cells(son + 1, 2) = Sheets("Invoice").Range("C7")
Sheets("Data").Cells(son + 1, 3) = Sheets("Invoice").Range("D7")
Sheets("Data").Cells(son + 1, 4) = Sheets("Invoice").Range("E7")
MsgBox "Registration Successful", vbApplicationModal
Sheets("Invoice").Range("B7:E7").ClearContents
Sheets("Data").Activate
End Sub
Dim son As Long
If Sheets("Invoice").Range("B7") = "" Or Sheets("Invoice").Range("C7") = "" Or _
Sheets("Invoice").Range("D7") = "" Or Sheets("Invoice").Range("E7") = "" Then MsgBox "Missing Data", _
vbCritical: Exit Sub
son = Sayfa1.Range("A" & Rows.Count).End(xlUp).Row
Sheets("Data").Cells(son + 1, 1) = Sheets("Invoice").Range("B7")
Sheets("Data").Cells(son + 1, 2) = Sheets("Invoice").Range("C7")
Sheets("Data").Cells(son + 1, 3) = Sheets("Invoice").Range("D7")
Sheets("Data").Cells(son + 1, 4) = Sheets("Invoice").Range("E7")
MsgBox "Registration Successful", vbApplicationModal
Sheets("Invoice").Range("B7:E7").ClearContents
Sheets("Data").Activate
End Sub
We used this code to find the first blank cell in column A and we assigned it to "son" variable :
son = Sayfa1.Range("A" & Rows.Count).End(xlUp).Row
No comments:
Post a Comment