Auto Insert Row With Predictive Data

reberryjr

Well-known Member
Joined
Mar 16, 2017
Messages
701
Office Version
  1. 365
Platform
  1. Windows
I am in desperate need of some assistance. I'm trying to teach myself VBA in Excel 2010 and am building an application for a friend. I've come to a point where I'm at a standstill until I can figure this piece out. I've posted this question a couple of times and haven't received any responses, so I'm hoping that if I change the question around a little bit, someone will be willing to assist.

The application tracks several things for her business, where she currently has 30 Clients. The difficult piece for me is tracking payments. As of now, I have everyone on one tab, updated via UserForms. What I'd like to have happen is for the application to "predict" when the next payment is due, and auto-insert a row and copies the data from the most recent entry, into a new row, adjusting the next payment due date.

In other words, a new row would be created using the data in row 3 (red font). All of the information present would be copied into the new row, except the DP Next Due value would say 11/04/17. Another new row would be created using the data in row 6 (red font), except the DP Next Due value would say 1/26/18.

Thoughts?


TodayUpdatedStatusFirstLastSuffixNameDP StatusDP StartDP Next DueDP AmtDP Pymt DateDP PaidDP Pymt StatusDP Freq
12/17/1710/24/17ActiveJennniferChuJennifer ChuActive09/04/1709/04/17$200.0009/04/17$200.00Paid TimelyM
12/17/1710/24/17ActiveJennniferChuJennifer ChuActive09/04/1709/04/17$200.0010/04/17$200.00Paid TimelyM
12/17/1710/24/17ActiveTomSmithJr.Tom Smith Jr.Active12/15/1712/15/17$200.0012/17/17$200.00Paid LateB
12/17/1710/24/17ActiveTomSmithJr.Tom Smith Jr.Active12/15/1712/29/17$250.00CurrentB
12/17/1711/30/17ActiveTomSmithJr.Tom Smith Jr.Active12/15/1701/12/18$250.00CurrentB

<colgroup><col span="2"><col><col><col><col><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi there,

I'd like to help, but don't quite understand what you're looking for.

What would prompt excel automatically insert the new row? Does it need to happen after a certain date has passed?

What information would be used to "predict" when the next payment is due?

-Matt
 
Upvote 0
Perhaps "predict" is the wrong term. It's really more of a calculation where "B" = Bi-Weekly, or 14 days, "M" = "Monthly" and "W" = "Weekly". I'm not certain how to best code the application to identify the need for the new row, with the next payment due. I wouldn't want it done only after a payment is made, in the event that someone is late. They should reflect 2 payments due, not just 1.
 
Upvote 0
If you want something to happen you normally have to say when this happens do this.

So what must happen to have the row copied to the next empty row.

Would it be when you enter a value some place in the row. Or when you activate the sheet or ??
 
Upvote 0
Originally, I was thinking that I could tie it to a button...something like "Calculate Next Payment Due". Then the User could somewhat create the rows when they want to. The issue I think would happen is, what if it's not done frequently? Would there be due dates that aren't calculated because the timing of the next due date doesn't coincide with when the button was clicked. I gave thought to giving every Client their own tab, but ranges would become very messy to create and keep up to date as new Clients come on board.
 
Upvote 0
With any cell in the last "Jennifer Chu" row selected, run the code below. Does this give you the desired result? If so, we can add to this to make it work for all customers based on their payment terms.

Sub
Add_Row_Jennifer()
'
' Add_Row Macro
'

'
Dim d As Date
ActiveCell.EntireRow.Select
Selection.Copy
ActiveCell.Offset(1, 0).Select
ActiveCell.EntireRow.Select
Selection.Insert Shift:=xlDown
ActiveCell.Offset(-1, 12).Select
d = DateAdd("m", 1, ActiveCell.Value)
ActiveCell.Offset(1, -3).Select
ActiveCell.Value = d
End Sub
 
Upvote 0
@The_Macrotect, thank you for the response! I ran that code and it inserted the row and pasted data into the new row. The DP Next Due reads "08/18/00" instead of 10/04/17. I also need to correct something I said, and advise of an aspect I left out of my earlier information. I don't want "everything" copied over. For example, I wouldn't want the DP Pymt Date copied, since the new payment may not have been made yet. Also, there are 5 sets of services offered. All of them have the same criterion as the last 8 columns in the table I provided, with only the first 2 characters being different. It was a large spreadsheet example to paste into here, so I didn't. These other services could have different due dates, amounts and payment frequencies, or none at all.

The VBA work I've done thus far has really been limited to entering data with UserForms, sorting and adding some formulas. I suspect that Excel isn't the best application for what I'm trying to do, but since my work frowns on Access, I'm kind of left without many options.
 
Upvote 0
@The_Macrotect, thank you for the response! I ran that code and it inserted the row and pasted data into the new row. The DP Next Due reads "08/18/00" instead of 10/04/17. I also need to correct something I said, and advise of an aspect I left out of my earlier information. I don't want "everything" copied over. For example, I wouldn't want the DP Pymt Date copied, since the new payment may not have been made yet. Also, there are 5 sets of services offered. All of them have the same criterion as the last 8 columns in the table I provided, with only the first 2 characters being different. It was a large spreadsheet example to paste into here, so I didn't. These other services could have different due dates, amounts and payment frequencies, or none at all.

The VBA work I've done thus far has really been limited to entering data with UserForms, sorting and adding some formulas. I suspect that Excel isn't the best application for what I'm trying to do, but since my work frowns on Access, I'm kind of left without many options.

Sorry, it looks like I left out a column when copying over the table, which caused the error. I've fixed it on my end. Which columns should be copied over, or if it's easier, which columns should not be copied?

I'm about to visit Mom and have dinner, so I'll take a look afterwords. :p
 
Upvote 0
Enjoy dinner and the time with your Mom!

The columns that should NOT copy down are DP Pymt Date and DP Paid.

<tbody>
</tbody>
 
Upvote 0
Hey, just wanted to let you know I've been working on it, and I think I'm almost there. I've got it to the point where it can insert a new row after the last row for a specific customer, and am almost done getting it to copy everything except the cells you said not to include from the last row.

By the way, would you like the "Updated" and "DP Pymt Status" cells to be pasted to the new row, or to be left out?

I'm off to bed, but let me know and I'll pick up again tomorrow after work.
 
Upvote 0

Forum statistics

Threads
1,215,350
Messages
6,124,430
Members
449,158
Latest member
burk0007

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