Moving data from one sheet to another

Sally mokhtar

New Member
Joined
Dec 8, 2020
Messages
10
Office Version
  1. 2016
Platform
  1. Windows
hello Everyone,

Am a Junior HR.. who is actually swamped in dozens of excel files that I have to manage monthly.

I have a certain task that i would really appreciate if I can automate !!

what I do is as follows:

Each month I receive a sheet with all our employees money in and out amounts( Dr. and Cr. amounts), i copy that amounts from the employees sheet and paste it in the main sheet to be reviewed by my boss.

the employees sheet:

Employees.xlsx
ABCDE
1AMOUNTDrCrTRADATE
2146.25146.250.00 11/15/2020Vesta
3246.25246.250.00 11/15/2020Cicely
4746.25746.250.00 11/15/2020Brenna
5-1,352.500.00-1,352.50 11/10/2020Shelli
6146.25146.250.00 11/15/2020Q.
7-162.750.00-162.75 11/10/2020Leona
8162.75162.750.00 11/28/2020Clara
944,000.0044,000.000.00 11/01/2020Maren
10-44,000.000.00-44,000.00 11/01/2020Honey
11196.25196.250.00 11/15/2020Klavdia
1272.6272.620.00 11/08/2020Rosina
1378,000.0078,000.000.00 11/01/2020Libby
14-78,000.000.00-78,000.00 11/01/2020Jerrie
15646.25646.250.00 11/15/2020Magdalene
165.545.540.00 11/10/2020Sammy-Jo
17-7,791.890.00-7,791.89 11/08/2020DeeAnn
18-546.250.00-546.25 11/10/2020Stone
19246.25246.250.00 11/15/2020Lucille
2010,000.0010,000.000.00 11/18/2020Edith
21-626.250.00-626.25 11/10/2020Ena
22-10,000.000.00-10,000.00 11/18/2020Adriènne
23526.25526.250.00 11/26/2020Miles
24-157.470.00-157.47 11/10/2020Evan
25-202.000.00-202.00 11/30/2020Pete
2610,000.0010,000.000.00 11/18/2020Brigham
27-10,000.000.00-10,000.00 11/18/2020Roma
28-342.500.00-342.50 11/10/2020Daniel
2963.2463.240.00 11/25/2020Gabriele
30-249,826.710.00-249,826.71 11/29/2020Jasper
31163.61163.610.00 11/28/2020Vesta
32-163.610.00-163.61 11/10/2020Cicely
333,377.413,377.410.00 11/08/2020Brenna
34-3,377.410.00-3,377.41 11/08/2020Shelli
35-8,606.020.00-8,606.02 11/08/2020Q.
36-646.250.00-646.25 11/10/2020Leona
37-162.750.00-162.75 11/10/2020Clara
38162.75162.750.00 11/28/2020Maren
Sheet1
Cell Formulas
RangeFormula
B2:B38B2=IF(A2>0,A2,0)
C2:C38C2=IF(A2<0,A2,0)


The main sheet:

1607510003276.png



what i do :

I have to copy the amounts in column B and C (DR. and Cr. amounts) from the first sheet mentioned (employees sheet) and paste in the main sheet (in the above pic)

Problem is:

when i copy the DR. and Cr. amount of an employee (for ex: Vesta) from employees sheet to paste in the Main sheet, i have to search within the tabs highlighted in the bottom of the excel sheet till i find that employee and paste the amounts in column B and C and so on.

Is there a Macro where i can copy the amounts of each employee from the first sheet and then go to the second sheet, search for that employee in the bottom tabs and paste those amounts automatically or I can't do that ?

Note: my boss doesn't want to change the main sheet so I've to stick with it.

if there is any way to automate it, that would literally save me 100 of hrs. copying and pasting 2400 employees data.

Thanks in advance.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Hi
Both excel file are open (Employee & MAINSHEET)
and place the code in a module in the Employee file, OK?
Then run the code
VBA Code:
Sub test()
   Application.ScreenUpdating = False
    a = Cells(2, 1).Resize(Cells(Rows.Count, 1).End(xlUp).Row - 1, 5)
    Windows("MAINSHEET.xlsx").Activate
    For i = 1 To UBound(a)
        On Error Resume Next
        With Sheets(a(i, 5))
            lr = .Cells(Rows.Count, 2).End(xlUp).Row
            .Cells(lr + 1, 2) = a(i, 2)
            .Cells(lr + 1, 3) = a(i, 3)
        End With
    Next
   Application.ScreenUpdating = True
End Sub
 
Last edited:
Upvote 0
Working perfectly, Mohadin !!!!

only one thing: i want the amount (163.61) to be after the last amount here 8,600 not at the top of the sheet
how can i fix that?
1607517501289.png

Hi
Both excel file are open (Employee & MAINSHEET)
and place the code in a module in the Employee file, OK?
Then run the code
VBA Code:
Sub test()
   Application.ScreenUpdating = False
    a = Cells(2, 1).Resize(Cells(Rows.Count, 1).End(xlUp).Row - 1, 5)
    Windows("MAINSHEET.xlsx").Activate
    For i = 1 To UBound(a)
        On Error Resume Next
        With Sheets(a(i, 5))
            lr = .Cells(Rows.Count, 2).End(xlUp).Row
            .Cells(lr + 1, 2) = a(i, 2)
            .Cells(lr + 1, 3) = a(i, 3)
        End With
    Next
   Application.ScreenUpdating = True
End Sub
 
Upvote 0
Yes
The Problem I can not see where the DEbet.... located in the sheet from your Pic.
 
Upvote 0
oh sorry about that

HYG

Others 1619208-AEA-Oct-2020.xls
ABCD
1 163.61 -
2
3
4
5 =================== ==================== ====================
6 DEBIT CREDIT BALANCE
7 =================== ==================== ====================
8 -
913,000.00 13,000.00
1013,000.00 -
1113,750.00 13,750.00
1213,750.00 27,500.00
1313,750.00 41,250.00
1413,720.00 54,970.00
1513,000.00 67,970.00
1613,750.00 54,220.00
1713,750.00 40,470.00
1813,750.00 26,720.00
1913,720.00 13,000.00
2013,000.00 -
2113,000.00 13,000.00
2213,000.00 -
2313,107.00 13,107.00
2413,107.00 -
258,600.00 8,600.00
268,600.00 -
27
28
29
30
31
32
33
34
Vesta
Cell Formulas
RangeFormula
C8C8=A8-B8
C9:C26C9=C8+A9-B9
 
Upvote 0
Try
VBA Code:
Sub test()
    Application.ScreenUpdating = False
    a = Cells(2, 1).Resize(Cells(Rows.Count, 1).End(xlUp).Row - 1, 5)
    Windows("MAINSHEET.xlsx").Activate
    For i = 1 To UBound(a)
        On Error Resume Next
        With Sheets(a(i, 5))
            .Cells(8, 1) = "DEBIT": .Cells(8, 2) = "CREDIT": Cells(8, 3) = "BALANCE"
            lr = .Cells(Rows.Count, 2).End(xlUp).Row
            .Cells(lr + 1, 2) = a(i, 2)
            .Cells(lr + 1, 3) = a(i, 3)
        End With
    Next
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Sorry for being late,
I did a lot of test every thing is OK in here
unless there is something in your MAIN file
 
Upvote 0
Hi Sally
have you replace the code with the one in #6
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,394
Members
448,957
Latest member
Hat4Life

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