Code to copy/past from one sheet to another

redspanna

Well-known Member
Joined
Jul 27, 2005
Messages
1,602
Office Version
  1. 365
Platform
  1. Windows
Hello all

Can some help be given to automate this simple process...

Copy value from last populated cells in coulmn D and E in sheet 1 and paste into first available cell in column B and C in sheet 2

Thanks in advance
 
Hi mumps - sorry , working with this last night I've got a possible addition - hope you can help


so this line of the code

Code:
Sheets("Sheet2").Cells(Sheets("Sheet2").Rows.Count, "E").End(xlUp).Offset(1, 0) = Target.Offset(0, -1)
can it be changed so that the text "Sent to" is added along with the copied value from column 5 ?

For example if column 5 holds the value Mr Excel, then the result for the new code would be


Sent to Mr Excel


Hope this makes sense, and appreciate any follow up work
 
Upvote 0

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I'm a little confused. The "copied value" that you mention would be in column 4 instead of column 5. Is this correct?
Code:
Target.Offset(0, -1)
and
Code:
Target.Offset(0, -2)
both refer to column E which is column 4.
 
Upvote 0
Sorry for confusion, I'll try and explain with a table below.


This is a sample of the sheet where the original data is kept
Date(blank)(blank)AgentDepositWithdraw
28AUG19Test110.00
28AUG19Test225.00

so using you suggested code, when a value in column 5 (deposit column) is added and RETURN key pressed I would like the phrase "Sent to" added along with the content of column 4 (Agent)

so result of this on sheet 2 would look like...


DateInOutBalanceRemarks
28AUG1925.00Sent To Test 2

or using you suggested code, when a value in column 6 (withdraw column) is added and RETURN key pressed I would like the phrase "Sent to" added along with the content of column 4 (Agent)

DateInOutBalanceRemarks
28AUG1910.00Sent To Test 1


the date in column 1 is auto populated so no need to copy this across...


Does that make more clear? - sorry again for confision
 
Upvote 0
Try:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Intersect(Target, Range("E:F")) Is Nothing Then Exit Sub
    Select Case Target.Column
        Case Is = 5
            Sheets("Sheet2").Cells(Sheets("Sheet2").Rows.Count, "C").End(xlUp).Offset(1, 0) = Target
            Sheets("Sheet2").Cells(Sheets("Sheet2").Rows.Count, "E").End(xlUp).Offset(1, 0) = "Sent to: " & Target.Offset(0, -1)
        Case Is = 6
            Sheets("Sheet2").Cells(Sheets("Sheet2").Rows.Count, "B").End(xlUp).Offset(1, 0) = Target
            Sheets("Sheet2").Cells(Sheets("Sheet2").Rows.Count, "E").End(xlUp).Offset(1, 0) = "Sent to: " & Target.Offset(0, -2)
    End Select
End Sub
 
Upvote 0
BOOM !!

Brilliant - thanks so much, appreciate your help !!
 
Upvote 0

Forum statistics

Threads
1,216,799
Messages
6,132,765
Members
449,759
Latest member
exnoob

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top