I'm not sure how this fits in your existing code, but you could cycle through
the input range (look for non-blanks in column D and plop those values in column
B of the database worksheet.
I figured the first "id" started in A2 (headers in row 1) and had something in
it.
Dim myRng as range
Dim LastRow as long
dim myCell as range
dim DestCell as range
dim CurrentId as String
with inputwks
lastrow = .cells(.rows.count,"D").end(xlup).row
set myrng = .range("A2:A" & lastrow)
end with
with historywks
set destcell = .cells(.rows.count,"A").end(xlup).offset(1,0)
end with
for each mycell in myrng.cells
if trim(mycell.value) = "" then
'don't change CurrentID
else
currentid = mycell.value
end if
'plop in id from this row or from previous row
destcell.value = currentid
'plop in bill#
destcell.offset(0,1).value = mycell.offset(0,3).value
'get ready for next one
set destcell = destcell.offset(1,0)
next mycell
====
You might end up trashing lots of code to replace it with something like
this.
wrote:
Dear Dave,
When I re-read it! its confusing!! My Apology, trying to stuff and shove in
everything!!.
The Part I am dumb with:
This is the part where I do not know how to modify the codes.
Currently the codes would transfer from
Payment---- Database in this structure (coz I really don't know how to
modify the codes).
Database
-----A--------------B-------C-------D---------E----------F-----
1----PV-1234------Bill 1---Bill 2--Bill 3----Bill 4-----Bill 5
************************************************
It's Still This:
Column A: Key In (manually)
Column D: Auto Reference
From Payment (Data Entry Form)
-----A---------B----------C---------D---------E
1----XYZ Ltd----------------------------------
2----PV-1234----------------------Bill 1----
3-----------------------------------Bill 2----
4-----------------------------------Bill 3----
5-----------------------------------Bill 4----
6-----------------------------------Bill 5----
When I hit the Save Data button, it will transfer to Database and clear cells.
RESULT:
Database
-----A----------------B
1----PV-0123--------Earlier Bill
2----PV-0123--------Earlier Bill
3----PV-1234--------Bill 1 <------here!!!
4----PV-1234--------Bill 2
5----PV-1234--------Bill 3
6----PV-1234--------Bill 4
7----PV-1234--------Bill 5
For Column A, I can use the 'fill blank cells link'.
For Column B: clueless!!!
Thanks for your patience.
--
Dave Peterson