Fixing populating values into textboxes based on showing data in listbox
Solved/Closed
abdelfatah_0230
Posts
73
Registration date
Thursday July 18, 2019
Status
Member
Last seen
July 23, 2022
-
Dec 2, 2020 at 07:59 AM
abdelfatah_0230 Posts 73 Registration date Thursday July 18, 2019 Status Member Last seen July 23, 2022 - Dec 25, 2020 at 09:35 AM
abdelfatah_0230 Posts 73 Registration date Thursday July 18, 2019 Status Member Last seen July 23, 2022 - Dec 25, 2020 at 09:35 AM
Related:
- Based on the values in cells b77 b81
- Code to move rows into another sheet based on certain values ✓ - Excel Forum
- Excel macro to create new sheet based on value in cells - Guide
- Instagram account based in wrong country - Instagram Forum
- Insert picture in Excel macro which takes the file name refrence - Excel Forum
- Based on the values in cells b77:b81, what function can automatically return the value in cell c77 ✓ - Excel Forum
5 responses
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Dec 8, 2020 at 12:16 PM
Dec 8, 2020 at 12:16 PM
Hi Abdel,
I'm getting an error when clicking the Show button, so can't test it, but I would try this:
Textbox4.Value = ListBox1.List(ListBox1.Count - 1, 5)
For the debit value.
Best regards,
Trowa
I'm getting an error when clicking the Show button, so can't test it, but I would try this:
Textbox4.Value = ListBox1.List(ListBox1.Count - 1, 5)
For the debit value.
Best regards,
Trowa
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Dec 24, 2020 at 11:38 AM
Dec 24, 2020 at 11:38 AM
Hi Abdel,
Yeah, your code snippets confused me. Add the following before the end of the code:
Best regards and see you in the next year!
Yeah, your code snippets confused me. Add the following before the end of the code:
For x = 0 To ListBox1.ListCount - 1 ListBox1.List(x, 4) = Format(ListBox1.List(x, 4), "$#,##00.0") ListBox1.List(x, 5) = Format(ListBox1.List(x, 5), "$#,##00.0") ListBox1.List(x, 6) = Format(ListBox1.List(x, 6), "$#,##00.0") Next x
Best regards and see you in the next year!
abdelfatah_0230
Posts
73
Registration date
Thursday July 18, 2019
Status
Member
Last seen
July 23, 2022
Dec 25, 2020 at 09:35 AM
Dec 25, 2020 at 09:35 AM
Many thanks ! for your a great assistance now the code works completely
best regards,
Abdelfatah
best regards,
Abdelfatah
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Dec 10, 2020 at 12:09 PM
Dec 10, 2020 at 12:09 PM
Hi Abdel,
I seem to be missing a library. Looks like I will have to recode your form, which might take a while since I'm quite busy around this time.
Best regards,
Trowa
I seem to be missing a library. Looks like I will have to recode your form, which might take a while since I'm quite busy around this time.
Best regards,
Trowa
abdelfatah_0230
Posts
73
Registration date
Thursday July 18, 2019
Status
Member
Last seen
July 23, 2022
Dec 10, 2020 at 12:48 PM
Dec 10, 2020 at 12:48 PM
never mind take your time
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Dec 14, 2020 at 12:14 PM
Dec 14, 2020 at 12:14 PM
Hi Abdel,
For some reason I got it to work today.
I put this piece of code at the bottom, before End Sub, to update the textboxes:
Hopefully it works for you.
Best regards,
Trowa
For some reason I got it to work today.
I put this piece of code at the bottom, before End Sub, to update the textboxes:
'To get Debit value Dim dValue As Long For x = 1 To ListBox1.ListCount - 1 dValue = dValue + ListBox1.List(x, 4) Next x TextBox4.Value = dValue 'To get Credit value Dim cValue As Long For x = 1 To ListBox1.ListCount - 1 cValue = cValue + ListBox1.List(x, 5) Next x TextBox5.Value = cValue 'To get Balance value Dim bValue As Long bValue = ListBox1.List(0, 6) + dValue - cValue TextBox6.Value = bValue
Hopefully it works for you.
Best regards,
Trowa
abdelfatah_0230
Posts
73
Registration date
Thursday July 18, 2019
Status
Member
Last seen
July 23, 2022
Updated on Dec 14, 2020 at 01:38 PM
Updated on Dec 14, 2020 at 01:38 PM
perfect updating I tested it works very well except one thing it gives me wrong values in two specific names I no know the reason but I think because there is no balance in first row in listbox like the rests of names which depends another sheet contains balance first of duration as is in the picture i'm talking about just credit and debit in this time the rests of textbox gives right value and I have last thing I try amending some lines to show format numbers and currency in column 4,5,6 in listbox but it gives me error , may you check it ,please?
cValue = cValue + Format(ListBox1.List(x, 4), "$#,##00.0")
cValue = cValue + Format(ListBox1.List(x, 5), "$#,##00.0")
cValue = cValue + Format(ListBox1.List(x, 6), "$#,##00.0")
Didn't find the answer you are looking for?
Ask a question
TrowaD
Posts
2921
Registration date
Sunday September 12, 2010
Status
Moderator
Last seen
December 27, 2022
555
Dec 22, 2020 at 12:07 PM
Dec 22, 2020 at 12:07 PM
Ok Abdel, both issues handled in the piece of code below:
Best regards,
Trowa
'To get Debit and Credit value Dim dValue, cValue As Long If TextBox3.Value = 0 Then 'When there is NO Balance First of Duration value For x = 0 To ListBox1.ListCount - 1 dValue = dValue + ListBox1.List(x, 4) Next x TextBox4.Value = Format(dValue, "$#,##00.0") For x = 0 To ListBox1.ListCount - 1 cValue = cValue + ListBox1.List(x, 5) Next x TextBox5.Value = Format(cValue, "$#,##00.0") Else 'When there IS a Balance First of Duration value For x = 1 To ListBox1.ListCount - 1 dValue = dValue + ListBox1.List(x, 4) Next x TextBox4.Value = Format(dValue, "$#,##00.0") For x = 1 To ListBox1.ListCount - 1 cValue = cValue + ListBox1.List(x, 5) Next x TextBox5.Value = Format(cValue, "$#,##00.0") End If 'To get Balance value Dim bValue As Long bValue = TextBox3.Value + dValue - cValue TextBox6.Value = Format(bValue, "$#,##00.0")
Best regards,
Trowa
abdelfatah_0230
Posts
73
Registration date
Thursday July 18, 2019
Status
Member
Last seen
July 23, 2022
Updated on Dec 23, 2020 at 03:46 AM
Updated on Dec 23, 2020 at 03:46 AM
awesome ! now the values show in listbox correctly ,but you seem misunderstood me about number format & currency I wanna showing number format in listbox ,I quota what I have ever told you
I hope fixing that
thanks again
I try amending some lines to show format numbers and currency in column 4,5,6 in listbox
I hope fixing that
thanks again
Updated on Dec 8, 2020 at 01:53 PM
here is the file again
https://www.dropbox.com/scl/fi/wcx1vdca811esal7vnd0m/report.xlsm?dl=0&rlkey=hu37p8osaf2vx0t8kvbhy2p4c
by the way it gives me error method of data number not fount about this word "count" i think this is typo you meant listcount not count but there is no changes still gives me wrong values
Updated on Dec 9, 2020 at 04:04 AM
as you see in textbox (debit ) should be value 60,000 and (credit) should be value 580,000 and the balance it depends on lastrow showing data in listbox I selected to understand , it should be 4,000 may be you ask yourself where get the first row in listbox it links with another sheet contains balance first of duration
I hope this help