|
-
Apr 16th, 2008, 09:33 AM
#1
Thread Starter
Don't Panic!
[RESOLVED] [Excel 2003] List box (pain)
Hi,
I hope some one can help and has done this before...
I would like to use a list box to show data from an array (data from an Access database).
Dumping data to the array - done....
Putting column headers... stumped.
In access with its list box, the first row (0) becomes the header. Understandable and works.
However if you fill the list box in Excel with Add Iteem and .List or .Column the first line is the first line of data. The headers remain blank.
Is there a fast way to get this working?
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Apr 16th, 2008, 10:37 AM
#2
Re: [Excel 2003] List box (pain)
 Originally Posted by Ecniv
Hi,
I hope some one can help and has done this before...
I would like to use a list box to show data from an array (data from an Access database).
Dumping data to the array - done....
Putting column headers... stumped.
In access with its list box, the first row (0) becomes the header. Understandable and works.
However if you fill the list box in Excel with Add Iteem and .List or .Column the first line is the first line of data. The headers remain blank.
Is there a fast way to get this working?
Use a ListView instead of a listbox and it will show you the headers...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Apr 29th, 2008, 05:55 AM
#3
Thread Starter
Don't Panic!
Re: [Excel 2003] List box (pain)
1) thanks - is it a normal control? if not - I cannot use it.
2) Not the point - if the list box claims it has headers, how come it won't let you set them.
Any advice appreciated (sorry for the delay in responding but I have been away for a week)
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Apr 29th, 2008, 06:21 AM
#4
Re: [Excel 2003] List box (pain)
 Originally Posted by Ecniv
1) thanks - is it a normal control? if not - I cannot use it.
2) Not the point - if the list box claims it has headers, how come it won't let you set them.
Any advice appreciated (sorry for the delay in responding but I have been away for a week)
1) What do you mean by normal controls?
2) yes you can set the headers in a listbox
Here is an example
Type anything in cells A2:C15
In Cell A1 type "Head1"
In Cell B1 type "Head2"
In Cell C1 type "Head3"
Now go to the form where the listbox is
In the properties changes these
BoundColumn: 3
ColumnCount: 3
RowSource: Sheet1!A2:C15
Now run the form
You will see that the headers of the listbox has been set to the values for A1 to C1
Hope this helps...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Apr 29th, 2008, 07:12 AM
#5
Re: [Excel 2003] List box (pain)
vb Code:
listbox1.columnheads = true
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Apr 29th, 2008, 07:22 AM
#6
Re: [Excel 2003] List box (pain)
listbox1.columnheads = true
Yes that too 
Thanks West. How could I forget it
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Apr 29th, 2008, 08:04 AM
#7
Thread Starter
Don't Panic!
Re: [Excel 2003] List box (pain)
thanks
but...
westconn1:
listbox1.columnheads = true
is the same as setting the listbox to HasHeaders=true (properties)
Koolsid:
1) What do you mean by normal controls?
The default you get in Excel 2003 (no installs or extras)
2) yes you can set the headers in a listbox
Uh well. I am not using a range. I am reading in values (usually from a recordset, sometimes from a file). If you use the Add Items method you can't use the headers. the add items to row 0 is the first row of data, negative numbers cause an error (I believe).
If you can have the hasheaders/column head = true and you are allowed to add items, how come they aren't the headers?
(possibly an MS bug - might just be I am thick)
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Apr 29th, 2008, 08:14 AM
#8
Re: [Excel 2003] List box (pain)
yes you can set the headers in a listbox
Uh well. I am not using a range. I am reading in values (usually from a recordset, sometimes from a file). If you use the Add Items method you can't use the headers. the add items to row 0 is the first row of data, negative numbers cause an error (I believe).
The only way I can think of is to copy the data from the recordset to a blank sheet in lieu of an array and then follow the example that I mentioned above... By the way did you try the above example?
Unfortunately you cannot directly amend to the column headers. It is automatically picked up by the system...
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
-
Apr 29th, 2008, 08:52 AM
#9
Thread Starter
Don't Panic!
Re: [Excel 2003] List box (pain)
In that case the headers can go do one then - useless... crap 'feature'.
Thanks for your help
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Apr 29th, 2008, 08:59 AM
#10
Re: [Excel 2003] List box (pain)
 Originally Posted by Ecniv
In that case the headers can go do one then - useless... crap 'feature'.
Thanks for your help 
A good exercise for the Heart is to bend down and help another up...
Please Mark your Thread " Resolved", if the query is solved
MyGear:
★ CPU ★ Ryzen 5 5800X
★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
★ Keyboard ★ TVS Electronics Gold Keyboard
★ Mouse ★ Logitech G502 Hero
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|