ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Listboxes (https://www.excelbanter.com/excel-programming/403896-listboxes.html)

C Brehm

Listboxes
 
I am pulling my hair out on this one (what little is left).

Have a listbox LBclerk1
When I set the value by code

Worksheets("daily").LBClerk1.Value = .Range("s" & rc).Value

The listbox itself does not update with the new value. As near as I can tell
that is because the boundvalue does not update to.
I have tried to set the bound value and the listindex but to no avail.
If I choose another worksheet and then chose the worksheet with the listbox
it will now show the correct value. Doing so in code with
worksheets("x").select does not work. What am I missing? Or, is there a
site that explains using listboxes and how to code for this?

Thanks Carl



JLGWhiz

Listboxes
 
There is a lot of information at this site. It also provides sample code.

http://support.microsoft.com/kb/126794

"C Brehm" wrote:

I am pulling my hair out on this one (what little is left).

Have a listbox LBclerk1
When I set the value by code

Worksheets("daily").LBClerk1.Value = .Range("s" & rc).Value

The listbox itself does not update with the new value. As near as I can tell
that is because the boundvalue does not update to.
I have tried to set the bound value and the listindex but to no avail.
If I choose another worksheet and then chose the worksheet with the listbox
it will now show the correct value. Doing so in code with
worksheets("x").select does not work. What am I missing? Or, is there a
site that explains using listboxes and how to code for this?

Thanks Carl




JLGWhiz

Listboxes
 
P.S. When you are not using code inside a With statement, do not use the
period in front of Range, [.Range]. It can confuse the compiler. You would
only use the .Range syntax if you are using something like With Worksheet(2).
Then the
[.] before the Range tells VBA that the Range belongs to Worksheet(2) and
not the ActiveSheet.

"C Brehm" wrote:

I am pulling my hair out on this one (what little is left).

Have a listbox LBclerk1
When I set the value by code

Worksheets("daily").LBClerk1.Value = .Range("s" & rc).Value

The listbox itself does not update with the new value. As near as I can tell
that is because the boundvalue does not update to.
I have tried to set the bound value and the listindex but to no avail.
If I choose another worksheet and then chose the worksheet with the listbox
it will now show the correct value. Doing so in code with
worksheets("x").select does not work. What am I missing? Or, is there a
site that explains using listboxes and how to code for this?

Thanks Carl




C Brehm

Listboxes
 
Thanks, but nothing there has helped. I looked through over 40 articles in
the knowledge base.
What really gets me is

Worksheets("daily").LBClerk1.Listindex

in the immediate widow works.
Does exactly what I want. But in code it returns an error.

PS.I only use .range is only used inside a with statement.

"JLGWhiz" wrote in message
...
There is a lot of information at this site. It also provides sample code.

http://support.microsoft.com/kb/126794

"C Brehm" wrote:

I am pulling my hair out on this one (what little is left).

Have a listbox LBclerk1
When I set the value by code

Worksheets("daily").LBClerk1.Value = .Range("s" & rc).Value

The listbox itself does not update with the new value. As near as I can
tell
that is because the boundvalue does not update to.
I have tried to set the bound value and the listindex but to no avail.
If I choose another worksheet and then chose the worksheet with the
listbox
it will now show the correct value. Doing so in code with
worksheets("x").select does not work. What am I missing? Or, is there a
site that explains using listboxes and how to code for this?

Thanks Carl






JLGWhiz

Listboxes
 
The three most common methods of returning a listbox value to a range in VBA
a

myRange = ListBox1.Value (For single select lists)
myRange = ListBox1.ListIndex(i) (When BoundColumn is at 0)
myRange = ListBox1.Selected(i) (For Multiselection lists)

I have not seen any other methods used, but that does not mean they are not
out there.


"C Brehm" wrote:

Thanks, but nothing there has helped. I looked through over 40 articles in
the knowledge base.
What really gets me is

Worksheets("daily").LBClerk1.Listindex

in the immediate widow works.
Does exactly what I want. But in code it returns an error.

PS.I only use .range is only used inside a with statement.

"JLGWhiz" wrote in message
...
There is a lot of information at this site. It also provides sample code.

http://support.microsoft.com/kb/126794

"C Brehm" wrote:

I am pulling my hair out on this one (what little is left).

Have a listbox LBclerk1
When I set the value by code

Worksheets("daily").LBClerk1.Value = .Range("s" & rc).Value

The listbox itself does not update with the new value. As near as I can
tell
that is because the boundvalue does not update to.
I have tried to set the bound value and the listindex but to no avail.
If I choose another worksheet and then chose the worksheet with the
listbox
it will now show the correct value. Doing so in code with
worksheets("x").select does not work. What am I missing? Or, is there a
site that explains using listboxes and how to code for this?

Thanks Carl








All times are GMT +1. The time now is 07:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com