Macro to move data from one worksheet to another in same workbook

Mldeuser

Well-known Member
Joined
Dec 27, 2008
Messages
573
Office Version
  1. 365
Platform
  1. Windows
Is it possible to have a macro compare two wokrsheets and move the totals from one sheet to the other worksheet.

Here are the worksheets:

Excel Workbook
BCDEFG
6Balance
7as ofMisc Bill BackEstimateAdjusted
81/31/20091/31/2009AccrualsKBSTenant Balance
9
10ADP, Inc-
11Albany Molecular Research-
12Alder Biopharmaceuticals-
13Behringer USA-
14Brunni-Colbath-
15Click & Mortar Multimedia-
16Kaseya-
17Science App International-
18Seattle Avionics Software-
19Team Moose-
20Transas USA-
21Great Clips-
22Service Alternative-
23Youngzee-
24Pacific Vascular-
25Pressler Engineer-
26Word of His Grace-
27Mirabilis Medica-
28-
29-
30
31
32Per Total Aged Delinquency Balance0.000.000.000.00
33
34Tenant Rec per A/R Balance Report@01/09(A/C 1110 & 1115)0.00
35Prepaid Rent per A/R Balance Report @01/09(A/C 2065)0.00
36
370.00
38
Prepaid Delinquent



Excel Workbook
ABCDEFGHIJ
7
8Invoice DateCategorySourceAmountCurrent1 Month2 Months3 Months4 Months
9
10
11RT1308-CB0654ADP, IncMaster Occupant Id: ADP, Inc-1Day Due: 1Delq Day:
124-102CurrentLast Payment:6/29/200974,155
13
146/20/2009UTIReimbursed UtilitiesCH7,864.7807,864.78000
156/20/2009UTIReimbursed UtilitiesCH2,088.1402,088.14000
166/20/2009UTIReimbursed UtilitiesCH7,923.4407,923.44000
176/20/2009UTIReimbursed UtilitiesCH1,486.2001,486.20000
187/16/2009UTIReimbursed UtilitiesCH9,394.849,394.840000
197/16/2009UTIReimbursed UtilitiesCH722.15722.150000
207/16/2009UTIReimbursed UtilitiesCH8,180.088,180.080000
217/16/2009UTIReimbursed UtilitiesCH3,081.593,081.590000
22
23UTIReimbursed Utilities40,74121,37919,363000
24ADP, Inc Total:40,74121,37919,363000
25
26
27RT1308-CB0662Albany Molecular Research, IncMaster Occupant Id: Albany M-1Day Due: 1Delq Day:
283-101InactiveLast Payment:3/5/200978,562
29
303/18/2009OPEOperating Expense RecoveNC-180.270000-180.27
313/18/2009OPEOperating Expense RecoveNC-180.270000-180.27
323/18/2009OPEOperating Expense RecoveNC-180.270000-180.27
333/18/2009OPEOperating Expense RecoveNC-1,401.360000-1,401.36
343/18/2009OPEOperating Expense RecoveNC-1,401.360000-1,401.36
353/18/2009OPEOperating Expense RecoveNC-1,401.360000-1,401.36
365/8/2009OPYOperating Exp Recov - PYNC-12,346.0000-12,346.0000
37
38OPEOperating Expense Recove-4,7450000-4,745
39OPYOperating Exp Recov - PY-12,34600-12,34600
40Albany Molecular Research, Inc Total:-17,09100-12,3460-4,745
41
42
43RT1308-CB0666Kaseya, IncMaster Occupant Id: Kaseya-1Day Due: 1Delq Day:
441-205CurrentLast Payment:7/1/20099,613
45
467/1/2009OPEOperating Expense RecoveCH76.8576.850000
47
48OPEOperating Expense Recove77770000
49Kaseya, Inc Total:77770000
50
Aged Delinquencies


I waould like the macro to compare column "C" on the prepaid delinquent worksheet to column "A" on the Aged delinquent worksheet and where they find a match brin the total amount from column "E" on the Aged delinquent worksheet to column "D" on the Prepaid Delinquent worksheet.

Additionally if there was an entry on the Aged delinquent worksheet that it would insert a new row on the Prepaid delinquent worksheet and copy in the information from the Aged delinquent worksheet.

Any help on this would be greatly appreciated.

Thanks
Mark
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Yes it is possible, but you give to little information as to what information ("totals" is very vague) is to be moved and were it is to be moved to. Also what triggers when the information is to be moved; a button pushed, a cell value changed, the worksheet deactivated, etc?

Post back the detail
 
Upvote 0
The Aged delinquency report is downloaded each month and copied and pasted into this workbook.

The totals would be the total per tenant from column "E" (for example the total for ADP is $40,741) this amount would go into cell D10 on the Prepaid Deliquency worksheet.

I would be using a command button on the Prepaid delinquency worksheet.

I hope this helps

Thank you for your time on this

Mark
 
Upvote 0
Whenever asking for solutions please give all the necessary information. Remember, we do not know anything about your operations, current reports and desired outcome except what you tell us.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
So far I think your asking to post the totals by A/R customer from the Aged Delinquencies (Aging) report to the Prepaid Delinquent (Prepaid)report by running a vba update procedure via a button on the Prepaid report. <o:p></o:p>
<o:p></o:p>
The Prepaid report already has a partial list of A/R customers. If a customer is reported on the Aging, but not on the Prepaid report, that customer is to be inserted to the Prepaid report in alphabetical order.
<o:p></o:p>
The total in column E for each customer in column A of the Aging is to be posted to column D of the matching customer in column C of the Prepaid report.
<o:p></o:p>
Questions:
Can the customer totals on the Aging be identified by the entries in column A having the word “Total:” at the end of the entry?
Are there any other entries other than the Total Customer that have the word “Total:” in them?
Is there a better way to determine the row that has the customer totals?
<o:p></o:p>
<o:p></o:p>
What information is to be added to the Prepaid report besides the customer name and total amount when a customer is missing from the Prepaid report?
<o:p></o:p>
Are both reports in the same workbook?
<o:p></o:p>
Are the matching names in both the reports always EXACTLY the same? (Most reports of this nature include the customer number. I don’t see the customer number in your sample reports.)
<o:p></o:p>
If there are any amounts in column D of the Prepaid report prior to running the update procedure, should they be erased?
<o:p></o:p>
It appears the Aging totals are rounded to the nearest dollar. Is that the way they are to be reported on the Prepaid report?
 
Upvote 0
So far I think your asking to post the totals by A/R customer from the Aged Delinquencies (Aging) report to the Prepaid Delinquent (Prepaid)report by running a vba update procedure via a button on the Prepaid report. This is correct
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
The Prepaid report already has a partial list of A/R customers. If a customer is reported on the Aging, but not on the Prepaid report, that customer is to be inserted to the Prepaid report in alphabetical order. - This is also correct

<o:p></o:p>
The total in column E for each customer in column A of the Aging is to be posted to column D of the matching customer in column C of the Prepaid report. - You are correct
<o:p></o:p>
Questions:
Can the customer totals on the Aging be identified by the entries in column A having the word “Total:” at the end of the entry? - Yes
Are there any other entries other than the Total Customer that have the word “Total:” in them? - No
Is there a better way to determine the row that has the customer totals? - No this is the only way
<o:p></o:p>
<o:p></o:p>
What information is to be added to the Prepaid report besides the customer name and total amount when a customer is missing from the Prepaid report? - That is all that needs to be brought over if the name is missing from the prepaid report (this will be a rare occurence)
<o:p></o:p>
Are both reports in the same workbook? Yes they are
<o:p></o:p>
Are the matching names in both the reports always EXACTLY the same? (Most reports of this nature include the customer number. I don’t see the customer number in your sample reports.) - They will always be the same from month to month
<o:p></o:p>
If there are any amounts in column D of the Prepaid report prior to running the update procedure, should they be erased? - No, each month prior to running the the update procedure the workbook is saved with a new name as we need to preserve the prior monthly workbooks. So the prior information should be overwritten.
<o:p></o:p>
It appears the Aging totals are rounded to the nearest dollar. Is that the way they are to be reported on the Prepaid report? No the pennies need to show on the prepaid report. I will fix the rounding on the aged report.

I have not figured out how to use the quote option so i changed the font color for my responses.

Thank you for your help with this.

Mark
 
Upvote 0
The names on the Aging and Prepaid reports are not EXACTLY the same in all cases. Therefore can not match names.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
Albany Molecular Research, Inc <<< Aging
Albany Molecular Research <<< Prepaid
<o:p></o:p>
Kaseya, Inc <<< Aging
Kaseya <<< Prepaid
<o:p></o:p>
Please advise on the above.
<o:p></o:p>
<o:p></o:p>
If there are any amounts in column D of the Prepaid report prior to running the update procedure, should they be erased? - No, each month prior to running the the update procedure the workbook is saved with a new name as we need to preserve the prior monthly workbooks. So the prior information should be overwritten.

<o:p></o:p>

<o:p></o:p>
I think the Prepaid amounts should be erased up front in the procedure before posting data from the Aging report. There may be a name on the Prepaid report that is not on the Aging report. If that’s the case the amount will remain unless pre-erased.
 
Upvote 0
The names on the prepaid worksheet can be changed to match the aged worksheet.

You are right that the prior amounts on the prepaid worksheet should be removed first.

Thanks
 
Upvote 0
I noticed teh names on teh Prepaid report are not sorted so if an Aging name is not on the Prepaid report I insert it at the top of the list of names.

If a name is in both reports but not spelled exactly the same the name in the Aging will be added to the Prepaid report.

Assume two sheets named Aging and Prepaid.

Code:
Option Explicit
Private Sub CommandButton1_Click()
    Dim c As Range
    Dim Aging As Worksheet
    Dim AgingTotals As Range
    Dim PrepaidNames As Range
    Dim CustomerName As String
    Dim FoundCustomer As Range
 
    Set Aging = Sheets("Aging")
    Set AgingTotals = Aging.Range("A1", Aging.Range("A65536").End(xlUp))
    Set PrepaidNames = Sheets("Prepaid").Range("C:C")
    For Each c In AgingTotals
        If Right(c, 6) = "Total:" Then
            CustomerName = Left(c, Len(c) - 7)
            Set FoundCustomer = PrepaidNames.Find(CustomerName, LookIn:=xlValues, lookat:=xlWhole)
            If FoundCustomer Is Nothing Then
                Range("C5").EntireRow.Insert
                Range("C5") = CustomerName
                Range("D5") = c.Offset(0, 4)
            Else
                FoundCustomer.Offset(0, 1) = c.Offset(0, 4)
            End If
        End If
    Next c
End Sub
 
Last edited:
Upvote 0
Thank you for the code.

I copied the code into module 14 and renamed the worksheets "Aging" and "Prepaid".

I then assigned the macro to a command button on the prepaid worksheet and when I ran it I received an error.

The error was Run-time error '9'
subscript out of range

When I selected debug the following line was highlighted.

Set PrepaidNames = Sheets("Prepaid").Range("C:C")

I am not sure what needs to be done at this point.

I also have one other question is it possible to use the sheet numbers instead of the assigned names so if a user decides to rename the aging tab the macro will still run.

Prepaid = Sheet33
Aging = Sheet24

Thank you again for all of your work on this

Mark
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,121
Members
452,381
Latest member
Nova88

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