Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Listboxes and changing colors


I've just experienced an anoying item for which I can't seem to find a
solution other then completely reprogramming a certain routine.

In listboxes with multiple items selected, when you change the front or
back color all items selected are de-selected. I can't find any
comments in the VBA books I have or Excel help. I also tried finding
something similar on this forum but to no avail.

Is there a solution for this anoying effect? Is there anybody whom
might be able to shed some light on this?

Thanks in advance for any ideas.

Leon


--
droopy928gt
------------------------------------------------------------------------
droopy928gt's Profile: http://www.excelforum.com/member.php...o&userid=30232
View this thread: http://www.excelforum.com/showthread...hreadid=528965

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Listboxes and changing colors

I've never noticed this, but I don't think I've ever changed the font <bg.

Maybe you could just keep track of what was selected before you do your stuff.
I build a userform with a listbox and a couple of buttons. This seemed to work
ok.

Option Explicit
Private Sub CommandButton1_Click()
Dim mySelected() As Boolean
Dim iCtr As Long
Dim TopItem As Long

With Me.ListBox1
TopItem = .TopIndex

ReDim mySelected(0 To .ListCount - 1)

For iCtr = 0 To .ListCount - 1
mySelected(iCtr) = .Selected(iCtr)
Next iCtr

If .Font.Name = "Arial" Then
.Font.Name = "Courier New"
Else
.Font.Name = "Arial"
End If

For iCtr = 0 To .ListCount - 1
.Selected(iCtr) = mySelected(iCtr)
Next iCtr

.TopIndex = TopItem
End With
End Sub
Private Sub CommandButton2_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim iCtr As Long
With Me.ListBox1
.MultiSelect = fmMultiSelectMulti
For iCtr = 1 To 10
.AddItem "asdf" & iCtr
Next iCtr
End With
End Sub


droopy928gt wrote:

I've just experienced an anoying item for which I can't seem to find a
solution other then completely reprogramming a certain routine.

In listboxes with multiple items selected, when you change the front or
back color all items selected are de-selected. I can't find any
comments in the VBA books I have or Excel help. I also tried finding
something similar on this forum but to no avail.

Is there a solution for this anoying effect? Is there anybody whom
might be able to shed some light on this?

Thanks in advance for any ideas.

Leon

--
droopy928gt
------------------------------------------------------------------------
droopy928gt's Profile: http://www.excelforum.com/member.php...o&userid=30232
View this thread: http://www.excelforum.com/showthread...hreadid=528965


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Listboxes and changing colors


Hi Dave,

Thanks for the reply. What you suggest is indeed what I meant with
reprogramming a certain routine.

I'd never noticed it either but due to a window being used for multiple
purposes I thought to be smart and change the back ground color for the
item selected so the user would immediatly see where he was in that
window. Normally this is no issue at all but with listboxes where
items are selected the selected items are lost and need to be
reselected which is annoying ofcourse.

Best regards,

Leon v/d Willik


--
droopy928gt
------------------------------------------------------------------------
droopy928gt's Profile: http://www.excelforum.com/member.php...o&userid=30232
View this thread: http://www.excelforum.com/showthread...hreadid=528965

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Listboxes and changing colors

I'm not quite sure what you're doing (and I didn't test this, either)...

But maybe you could have two listboxes--one visible and one hidden. Then
hide/show the ones you want.

droopy928gt wrote:

Hi Dave,

Thanks for the reply. What you suggest is indeed what I meant with
reprogramming a certain routine.

I'd never noticed it either but due to a window being used for multiple
purposes I thought to be smart and change the back ground color for the
item selected so the user would immediatly see where he was in that
window. Normally this is no issue at all but with listboxes where
items are selected the selected items are lost and need to be
reselected which is annoying ofcourse.

Best regards,

Leon v/d Willik

--
droopy928gt
------------------------------------------------------------------------
droopy928gt's Profile: http://www.excelforum.com/member.php...o&userid=30232
View this thread: http://www.excelforum.com/showthread...hreadid=528965


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
changing colors widman Excel Discussion (Misc queries) 3 October 16th 06 12:53 AM
Changing colors? Lee Excel Discussion (Misc queries) 1 May 23rd 06 03:11 AM
Changing the colors Prado Excel Discussion (Misc queries) 2 March 3rd 05 06:41 PM
Changing colors davetteb Charts and Charting in Excel 1 February 18th 05 12:17 AM
Changing colors scantor145[_5_] Excel Programming 1 September 29th 04 03:57 PM


All times are GMT +1. The time now is 09:55 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"