Userform listbox items to worksheet issue

cherrydee

New Member
Joined
Jan 1, 2017
Messages
13
Hi, i have a userform where the input fields are copied to a worksheet.
Supposing i have 5 columns, a-serial number, b-debit code, c-debit amount, d-credit code, e-credit amount.
there are cases where the number of debit amount does not equal to the credit. Example: serial # 2018-001 has 1 debit amounting to 1,000 and 2 credits amounting to 500,500. The 2 credits are written as 2 rows and under only 1 serial number.
What i am doing is, i use the debit amount column to check the lastrow which works perfectly if both debit and credit has equal rows.
But when debit has 1 row and credit has 2 rows, my next transaction will add itself to the 1 blank cell in the previous debit.
Any workaround? I'm not so good in programming and I've been frustrated the whole day :/
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Use the serial number column Lastrow for all the credit and or debit column lastrow.

It may help to show us your script.
 
Last edited:
Upvote 0
Hi,
Always helpful if you can post code having difficulty with but as a suggestion, if you are just testing for last used row on a single column like this

Rich (BB code):
Lastrow = Cells(Rows.Count, "A").End(xlUp).Row

then you may be able to resolve your issue by using Rang.Find function

Rich (BB code):
On Error Resume Next
    NewRow = Worksheets("Sheet1").Cells.Find(What:="*", After:=Worksheets("Sheet1").Range("A1"), _
                            Lookat:=xlPart, LookIn:=xlFormulas, SearchOrder:=xlByRows, _
                            SearchDirection:=xlPrevious, MatchCase:=False).Row + 1
    On Error GoTo 0

This should find the next blank row number in your worksheet regardless of which cells have data entered.
Change sheet name shown in RED as required.

If still having issues, post back with your code.

Hope Helpful

Dave
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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