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>
 
I think were both getting a bit lost here.
1) Your dictionary reads all client accounts from StatsClientID into cobo_ClientID If StatsClientID is dynamic, that means you have a dynamic list of clients in the combobox. As long as the sheet names are the same as the client Ids then you have a dynamic list of sheet names. Are you happy with this?

2) Assuming you are only updating 1 client at a time on the userform, then you can use something like I posted in post#25 to find the last/next row in the relevant sheet. Are you happy with this?

3) Could you show us how your sheets are laid out. I have no idea what you mean by
it isn't tying to the max updated date
 
Last edited:
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Sorry about that. It's probably me not explaining what I'm trying to do correctly. Here's a level view:
1. A 3 character Client ID (ex. RB1, RB2, QJ4) is assigned when a new Client is added. (Done. This is housed on a sheet entitled "Bios" and has a dynamic range tied to it.)
2. A separate sheet is created for each Client, named the same as their Client ID. (Done.)
3. When the User needs to update the financials on a Client's sheet, I want them to:
3.a. Click a command button that launches a UserForm. (Done.)
3.b. Select the appropriate Client Id from cobo_ClientID. (Done.)
3.c. The UserForm would then identify the correct sheet (where the sheet name equals the cobo_ClientID value). (Here's where I'm struggling.)
3.d. The UserForm pulls in the data elements present on the UserForm, from the max Updated date. (I think I can do this if I can figure out step 3.c.)​
As the User makes updates to each Client sheet (individually), a new row would be created to house the updates. Each time, the Updated field gets a date, letting me identify the MAX updated record.

The unique Client sheets are laid out like this. Note that there are 4 more sets of data that are similar to columns F:O, with slightly different column headers.
TodayUpdatedStatusClient IDNameDP StatusDP StartDP Pymt AmtDP Next DueDP FreqDP Pymt StatusDP PaidDP Paid OnDP Net DueDP End

<tbody>
</tbody>
 
Upvote 0
OK for 3.c try something like this
Code:
Private Sub cobo_ClientID_Change()
   Dim Sht As String
   
   Sht = Me.cobo_ClientID.Value
   [COLOR=#ff0000]TextBox1[/COLOR].Value = Sheets(Sht).Range("A5").Value
   
End Sub
Changing textbox name & range accordingly
 
Upvote 0
That works great to pull in the correct name. I tried to code to get the other fields, using this code and I'm getting an "Invalid Qualifier" error at the red font.
Code:
Private Sub cobo_ClientID_Change()

Dim Sht As String
Dim LastRow As Long


Sht = Me.cobo_ClientID


LastRow = [COLOR=#ff0000]Sht[/COLOR].Range("E" & RowsCount).End(xlUp).Row


txt_Name = Sheets(Sht).Range("E2").Value
txt_DPAmt = Sheets(Sht).Range("H" & LastRow).Value






End Sub
 
Upvote 0
That should be done the same as 2 lines below
 
Upvote 0
I'm sorry, but what 2 lines? In thinking about it, I could make looking at row 2 work if I sort each sheet by the updated column, in descending order. I'll just have to account for that in the next phase, when I add formulas to calculate gains and losses.
 
Last edited:
Upvote 0
Apologies, that wasn't very clear.
I meant the next 2 lines in your code, ie Sheets(sht)
 
Upvote 0
I stepped through the code and it was failing at that spot in red font. However, I "think" I may have gotten it with this code. I've tested it with two values on two test sheets and it seems to be working so far. I think the issue was that the way I was coding for LastRow in other places, had extra variables that aren't really required and I was being thrown off.

Code:
Private Sub cobo_ClientID_Change()

Dim Sht As String
Dim LastRow As Long


Sht = Me.cobo_ClientID


With ActiveSheet
    LastRow = .Cells(.Rows.Count, "E").End(xlUp).Row
End With


txt_Name = Sheets(Sht).Range("E").Value
txt_DPPymtAmt = Sheets(Sht).Range("H" & LastRow).Value






End Sub
 
Upvote 0

Forum statistics

Threads
1,214,642
Messages
6,120,698
Members
448,979
Latest member
DET4492

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