View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
kirkm[_8_] kirkm[_8_] is offline
external usenet poster
 
Posts: 166
Default Some expert help needed

On Wed, 3 Jun 2009 14:35:04 +0200, "Per Jessen"
wrote:

Hi Kirk,

RowSource is as you say used to load a listbox with values. Control Source
will hold the selected value, and will also be the selected value next time
the userform is activated.

frmTest.ListBox1.RowSource = "Test!A1:I5"
frmTest.ListBox1.ControlSource="Test!K1"

Hopes this helps.


Per, I'm not sure. The whole problem is twofold. I can't figure out
what ControlSource is or does. In your example above would is the
value in K1 and what is the result of with and without it?

If I knew that, it might shed some light on this.... I want to open
a Form+ ListBox with a selected line highlit. Most times it's
0 for line 1, but sometimes another line is wanted. This number is
variable mLine in the following code.

Call WriteCell("Test", mLine, "P3")
List1.ControlSource = "Test!P3"
List1.ListIndex = mLine
List1.Selected(mLine) = True
List1.BoundColumn = 0
DoEvents

It works reasonably often BUT every so often the wrong
line is highlit and isn't what mLine is. It's a right ******* because
if you put a STOP in the code to check values, it NEVER fails
to be correct. I've also just found a Sleeep 1000 (from
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
also seems to make it work.
So it seems some kind of delay is needed. Has anyone else struck
this ? Is the above code correct ?

Thanks - Kirk