Copying rows into different 2 different spreadsheets based on 2 colums

N1x0N92

New Member
Joined
Jul 23, 2019
Messages
7
Hi

First post so hopefully I can give enough information for someone to help me :)

Im trying to set up a spreadsheet that will allow a colleague to enter information on the MASTER that will then feed into other sheets.

The below a copy from the master sheet...…

DateDescriptionCost CentreAmountReconciled
01/04/2019Money in 1Donations100Apr-19
02/04/2019Money out 2Donations-100May-19
03/04/2019Money in 2Friends of School50Jun-19
04/04/2019Money out 3School Trips-50Jul-19
05/04/2019Money in 3School Trips70Aug-19
06/04/2019Money out 4School Trips-70Sep-19
07/04/2019Money in 4Donations Income40Oct-19
08/04/2019Money out 5Donations Expenditure-40Nov-19
09/04/2019Money in 5School Trips95Dec-19
10/04/2019Money out 6School Trips-95Jan-20
11/04/2019Money in 6Donations45Feb-20
12/04/2019Money out 7Donations-45Mar-20
13/04/2019Money in 7School Trips20
14/04/2019Money out 8School Trips-20
15/04/2019Money in 8Donations10
16/04/2019Money out 9Donations-10

<tbody>
</tbody>
<strike></strike>
I then have a sheet for each Cost Centre and a sheet for reconciled for example (Donations and April 19)

what I then need to happen is the whole row to be copied into the relevant cost centre and also the reconciled month.

is this possible?

Any help would be fantastic.

Kind regards
<strike></strike>
<strike></strike>

<tbody>
</tbody>
 
hi

"""Or do you want the one double clicked on just do nothing if it has already been copied over. """

the above would be perfect

kind regards
 
Upvote 0

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try this:
When you double click on column 3
That cell will be colored Red and the script continues.
If that cell is already colored Red the script will tell you that row has already been copied over and the script will stop and do nothing.

Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified  8/8/2019  3:41:50 AM  EDT
If Target.Column = 3 Then
Cancel = True
On Error GoTo M
If Target.Interior.Color = vbRed Then MsgBox "That row has already been copied" & vbNewLine & "I will stop this script": Exit Sub
Dim Lastrowc As Long
Dim ans As String
Dim Lastrowe As Long
ans = Format(Cells(Target.Row, "E"), "MMM-YY")
Lastrowc = Sheets(Cells(Target.Row, "C").Value).Cells(Rows.Count, "A").End(xlUp).Row + 1
Lastrowe = Sheets(ans).Cells(Rows.Count, "A").End(xlUp).Row + 1
Rows(Target.Row).Copy Sheets(Cells(Target.Row, "C").Value).Rows(Lastrowc)
Rows(Target.Row).Copy Sheets(ans).Rows(Lastrowe)
Target.Interior.Color = vbRed
End If
Exit Sub
M:
MsgBox "You do not have a sheet by that name"
End Sub
 
Upvote 0
Hi

this is brilliant!

i have another request, can the script stope copying after column F.

so when it copies the date into the new sheets it copies colums A to F but then leaves the data i have manaully keyed in the new spreadsheets after that?

Thanks in advance.
 
Upvote 0
Try this:
Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified  8/14/2019  1:09:20 PM  EDT
If Target.Column = 3 Then
Cancel = True
On Error GoTo M
If Target.Interior.Color = vbRed Then MsgBox "That row has already been copied" & vbNewLine & "I will stop this script": Exit Sub
Dim Lastrowc As Long
Dim ans As String
Dim Lastrowe As Long
ans = Format(Cells(Target.Row, "E"), "MMM-YY")
Lastrowc = Sheets(Cells(Target.Row, "C").Value).Cells(Rows.Count, "A").End(xlUp).Row + 1
Lastrowe = Sheets(ans).Cells(Rows.Count, "A").End(xlUp).Row + 1
Cells(Target.Row, 1).Resize(, 6).Copy Sheets(Cells(Target.Row, "C").Value).Cells(Lastrowc, 1)
Cells(Target.Row, 1).Resize(, 6).Copy Sheets(ans).Cells(Lastrowe, 1)
Target.Interior.Color = vbRed
End If
Exit Sub
M:
MsgBox "You do not have a sheet by that name"
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,331
Messages
6,124,312
Members
449,152
Latest member
PressEscape

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