Adding values to listbox

vidario

New Member
Joined
Sep 27, 2012
Messages
6
Hello everyone, I'm a real newbie in vba, but I wish I could do this:
I have a spreadsheet like the one in the picture. In the first column I have dates, amounts in the second and third categories (which may or may not be included). What I would like is to get a listbox on a userform bringing me back each category once and the total of that category (as in the red box image)

How can I do?

thanks

 
Thank you so much. Just another question (I hope this will be the last :)). I'm not able to filter the dates on my sheet using a variable date from my userform.
The code I used is this:

Code:
Sheets("Foglio1").Activate

Sheets("Foglio1").Range(Cells(1, 1), Cells(ultimariga1, ultimacolonna1)).AutoFilter Field:=3, Criteria1:=filtro, _
Operator:=xlAnd, Field:=1, Criteria2:=">=" & Format(UserForm1.fromdate, "MM/dd/yyyy")

The code doesn't give any error but it doesn't work. If my "fromdate" on the form is 30/09/2012 (I'm italian so my dates are in the dd/mm/yyyy format) it also filters earlier dates (16/09/2012).

What am I doing wrong?

Thanks again
 
Upvote 0

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
Try replacing...

Code:
Criteria2:=">=" & Format(UserForm1.fromdate, "MM/dd/yyyy")

with

Code:
Criteria2:=">=" & CLng(CDate(UserForm1.fromdate))
 
Upvote 0
Hi All,

Can anyone please explain why the redim preserve statement is required in the code and why is that the list just shows the category's and not it's values? How can i add these values to show in the 2nd column of listbox also?

Domenic has been a great help and i know he is busy at the minute so if anyone else could explain that would be grand.

Thank You


ReDim Preserve aData(1 To 2, 1 To c) Me.ListBox1.List = Application.Transpose(aData)</pre>
 
Upvote 0
Hi All,

Can anyone please explain why the redim preserve statement is required in the code and why is that the list just shows the category's and not it's values? How can i add these values to show in the 2nd column of listbox also?

Domenic has been a great help and i know he is busy at the minute so if anyone else could explain that would be grand.

Thank You


ReDim Preserve aData(1 To 2, 1 To c) Me.ListBox1.List = Application.Transpose(aData)

Bump Anyone
 
Upvote 0
Hi Domenic,

i guess it is only you that will help and explain why it is not pulling through values also in list box.

i know your busy so i guess il have to wait until u have some free time
thanks
 
Upvote 0

Forum statistics

Threads
1,215,140
Messages
6,123,266
Members
449,093
Latest member
Vincent Khandagale

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