kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
So I used this code at the early stage to update my database. But as I move forward, I realized that there are series of pitfalls that await me.
I think I have a problem with the loop counter of my first loop and I would need some form of help.
1. I want to first count the number of filled boxes immediately after loading or fetching the data from the database.
And this is when I click on the "Edit/Update button":
a. If the currently filled boxes are more than those I recorded during the data loading process, then I would want to expand my database by adding more rows just after the string "DAILY TOTALS" under column A so that I can accommodate the new expansion coming from the form controls.
b. If the filled boxes are less than those I recorded during the data loading process, then I would want to contract or shrink my database by deleting more rows in between the date and the string "DAILY TOTALS" so that I can accommodate the new contraction/reduction coming from the form controls.
2. Once I have points/steps a and b verified and passed, I proceed with sending/updating the database. By then, the data should fit exactly at the respective locations.
3. This means that I need to adapt/adjust the for loop as:
I really need your help to fix this (Better ways are appreciated)
Thanks
I think I have a problem with the loop counter of my first loop and I would need some form of help.
1. I want to first count the number of filled boxes immediately after loading or fetching the data from the database.
And this is when I click on the "Edit/Update button":
a. If the currently filled boxes are more than those I recorded during the data loading process, then I would want to expand my database by adding more rows just after the string "DAILY TOTALS" under column A so that I can accommodate the new expansion coming from the form controls.
b. If the filled boxes are less than those I recorded during the data loading process, then I would want to contract or shrink my database by deleting more rows in between the date and the string "DAILY TOTALS" so that I can accommodate the new contraction/reduction coming from the form controls.
2. Once I have points/steps a and b verified and passed, I proceed with sending/updating the database. By then, the data should fit exactly at the respective locations.
3. This means that I need to adapt/adjust the for loop as:
Code:
For i = 1 to (Something)
I really need your help to fix this (Better ways are appreciated)
Thanks
Code:
Dim findvalue As Range, lr&, j&
Dim EXP As Worksheet, c&, i&
Set EXP = Sheets("EXPENSE")
lr = EXP.Cells(Rows.Count, "A").End(xlUp).Row
If lr < 4 Then lr = 4
Set findvalue = EXP.Range("A4:A" & lr).Find(what:=CDate(exp1), LookIn:=xlValues, lookat:=xlWhole)
findvalue = CDate(exp1)
c = 2
For i = 1 To 15
For j = 0 To 1
findvalue.Offset(i, j) = Controls("exp" & c + j).Value
Next j
c = c + 2
Next i
[//code]
See sample image for worksheet below:
[ATTACH type="full"]30692[/ATTACH]