RE: reply
- From: CAMoore <CAMoore@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 22 Oct 2008 13:31:01 -0700
Thank you. I appreciate all your time and effort in trying to help me.
Maybe I'll give it a rest and try another approach and/or a light bulb will
go off in my head tomorrow. That's the way it usually works. I was really
happy to get the code to work that lists all the file names and create
hyperlinks to them though. I'm just trying to make it user friendly now so
users will have an interface to work with.
Thanks again.
--
Other programming languages I''''ve used are: Cobol, C++, Informix Database,
and Unix.
"FSt1" wrote:
hi.
not sure but 2007 may be a factor. i'm using 2003. so sending me the file
wouldn't work since i can't open it. sorry. also the code does work in 2003
and i do know they have changed some things in 2007 in order to add some of
the new features but i am not sure if this is the cause of this code not
working on your end. i am reading up on 2007 so i do know some but my direct
experience is nil and any new code would be beyond me at this point since i
can't run or test in 2007.
perhaps a mvp could step in now and bail both of us out. if not sorry for
any bum steers. repost and state that you are using 2007 up front.
Regards
FSt1
"CAMoore" wrote:
Sorry. I realize I went back and forth with ComboBox and ListBox. What I'm
trying to get working with RowSource right now is the ListBox. Here is the
code you last posted and I edited as per my *** and UserForm name, and it
didnt work. :( I'm using Excel 2007. Maybe I could email my spread*** to
you???
Private Sub UserForm2_Initialize()
'TextBox2.Value = Date
Dim lr As Long
Dim r As Range
lr = Sheets("Filenames").Cells(Rows.Count, "A").End(xlUp).Row
Set r = Range("A2:A" & lr)
Me.ListBox1.RowSource = "Filenames!" & r.Address
CommandButton1.SetFocus
End Sub
--
Other programming languages I''''ve used are: Cobol, C++, Informix Database,
and Unix.
"FSt1" wrote:
hi
now i'm confused. you said you made a mistake about posted list box vs.
combo box so now i'm not sure which one we are working with. no matter. the
two work very similar in code.
you first try should have worked. I didn't test second try. not sure at this
point why it didn't work so i drug out my play form, put a list box(?) on it,
put my code in it and it loaded right up at initialization. here is my code
from my play form.
Private Sub UserForm_Initialize()
TextBox2.Value = Date
Dim lr As Long
Dim r As Range
lr = Sheets("sheet2").Cells(Rows.Count, "A").End(xlUp).Row
Set r = Range("A2:A" & lr)
Me.ListBox1.RowSource = "Sheet2!" & r.Address
CommandButton1.SetFocus
End Sub
again, i use generic *** names but the list box loaded with the list i
have on *** 2. i doubled the list length and it loaded the new list. i
opened the form from *** 1.
I did assume that your list was in column A. if not change the code in this
line to the column your list is in....
lr = Sheets("sheet2").Cells(Rows.Count, "A").End(xlUp).Row
works in xp.
regards
FSt1
"CAMoore" wrote:
I've tried two different ways in UserForm2_Initialization and neither one
worked :(
***********
** Try #1: **
***********
Public Sub UserForm2_Initialize()
ColCnt = Active***.UsedRange.Columns.Count
Set rng = Active***.UsedRange
Dim lr As Long
Dim r As Range
With ListBox1
.ColumnCount = ColCnt
.RowSource = rng.Address
cw = ""
For c = 1 To .ColumnCount
cw = cw & rng.Columns(c).Width & ";"
Next c
.ColumnWidths = cw
.ListIndex = 0
End With
lr = Sheets("FileNames").Cells(Rows.Count, "A").End(xlUp).Row
Set r = Range("A2:A" & lr)
Me.ListBox1.RowSource = "Filenames!" & r.Address
End Sub
***********
** Try #2: **
***********
Public Sub UserForm2_Initialize()
Dim rng As Range
Dim LastRow As Long
ThisWorkbook.Worksheets("Main").Activate
LastRow = Worksheets("Filenames").Range("A65536").End(xlUp).Row
With ThisWorkbook.Sheets("Filenames")
Set rng = .Range("A1:A" & LastRow)
End With
With ListBox1
For Each cell In rng.Cells
AddItem cell.Value
Next cell
End With
End Sub
--
Other programming languages I''''ve used are: Cobol, C++, Informix Database,
and Unix.
"FSt1" wrote:
hi
accually that's userform2 initialazation code. listboxs and combobox don't
have an initialation evert. forms do.
try this....
Private Sub UserForm2_Initialize()
ColCnt = Active***.UsedRange.Columns.Count
Set Rng = Active***.UsedRange
dim lr as long
dim r as range
With ListBox1
.ColumnCount = ColCnt
.RowSource = Rng.Address
cw = ""
For c = 1 To .ColumnCount
cw = cw & Rng.Columns(c).Width & ";"
Next c
.ColumnWidths = cw
.ListIndex = 0
End With
lr = Sheets("FileNames").Cells(Rows.Count, "A").End(xlUp).Row
Set r = Range("A2:A" & lr)
Me.ComboBox1.rowsource = "Filenames!" & r.Address
End Sub
untested. watch for typos
regards
FSt1
- References:
- ComboBox RowSource Dynamic
- From: CAMoore
- RE: ComboBox RowSource Dynamic
- From: FSt1
- reply
- From: FSt1
- RE: reply
- From: CAMoore
- RE: reply
- From: FSt1
- RE: reply
- From: CAMoore
- RE: reply
- From: FSt1
- ComboBox RowSource Dynamic
- Prev by Date: Counting using multiple criteria
- Next by Date: RE: Counting using multiple criteria
- Previous by thread: RE: reply
- Next by thread: RE: reply
- Index(es):