View Single Post
 
Old 04-01-2017, 11:02 PM
pourmalla pourmalla is offline Windows 10 Office 2016
Novice
 
Join Date: Apr 2017
Posts: 1
pourmalla is on a distinguished road
Default Excel VBA macro to copy specific rows and delete it

Hi to every one;
At first thanks in advance to everyone that read my question, and specially help me to fix my problem.
Here what I want to do:
1. I have 2 worksheet named Pending & Records.
2. Column in Pending worksheet: A: Date, B: Delivery To, C: Delivery to office, D: Delivery to Manager, E: Subject, F: Date & G: Letter No.
3. Column in Records worksheet: A: Date, B: Letter No. & C: Subject.
4. When entered number in cell G (Letter No.) of Pending worksheet, the below cells copy to specified cells in Records worksheet.
· E (Subject) in Pending worksheet sit in C (subject) of Records worksheet.
· F (Date) in Pending worksheet sit in A (Date) of Records worksheet.
· G (Letter No.) in Pending worksheet sit in B (Letter No.) of Records worksheet.
5. Deleted the row that copy in Pending worksheet.
6. Sort the rows in Records worksheet according to Letter No. (Column C).
This is codes that I write for what I want to do (not work good) and some screenshot:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 6 Then
If Len(Target.Value) > 0 Then
Dim r As Range
Dim a As String
Dim b As String
b = "sheet3!A" & Sheet1.Cells(1, 9) + 3 & ":C" & Sheet1.Cells(1, 9) + 3
a = "E" & Target.Row & ":G" & Target.Row
Dim r1, r2 As Range
r1 = Sheet1.Range(a)
Sheet2.Range(b).Value = r1
Sheet1.Range(a).EntireRow.Delete
End If
End If
End Sub
Attached Files
File Type: xlsm Please Help.xlsm (20.2 KB, 8 views)

Last edited by pourmalla; 04-02-2017 at 12:13 AM. Reason: upload file
Reply With Quote