Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
more forms questions...
I have the following code to initialize a form that gets all the named
ranges in a workbook. Private Sub UserForm_Initialize() SourceTextBox.SetFocus For Each nName In Names Me.LeftBox.AddItem (nName.Name) Next nName End Sub This works great but what I want to do now is initialize the form putting the cursor in the SourceTextBox then taking as input from the textbox the name of the sheet from where I want to get the named ranges only from that sheet something like this... Private Sub UserForm_Initialize() SourceTextBox.SetFocus End Sub I get a Form that is empty and the cursor in the correct place. I enter the name of the sheet I am interested in -- "data" ( goto the sheet read the named ranges of that sheet then insert them in the correct list box then wait for the rest of the button acctions (this code is already done)) something like this: Private sub SourceTextBox_AfterUpdate()'entered "data" then enter For Each nName In What do I put here ???? Me.LeftBox.AddItem (nName.What do I put here ???) Next nName end sub Thanks Chris |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
more forms questions...
Hi Chris
Try: Private Sub SourceTextBox_AfterUpdate() Dim nName As Name For Each nName In ThisWorkbook.Names If nName.RefersToRange.Parent.Name = Me.SourceTextBox.Text Then Me.LeftBox.AddItem nName.Name End If Next nName End Sub Hope this helps Rowan Chris Salcedo wrote: I have the following code to initialize a form that gets all the named ranges in a workbook. Private Sub UserForm_Initialize() SourceTextBox.SetFocus For Each nName In Names Me.LeftBox.AddItem (nName.Name) Next nName End Sub This works great but what I want to do now is initialize the form putting the cursor in the SourceTextBox then taking as input from the textbox the name of the sheet from where I want to get the named ranges only from that sheet something like this... Private Sub UserForm_Initialize() SourceTextBox.SetFocus End Sub I get a Form that is empty and the cursor in the correct place. I enter the name of the sheet I am interested in -- "data" ( goto the sheet read the named ranges of that sheet then insert them in the correct list box then wait for the rest of the button acctions (this code is already done)) something like this: Private sub SourceTextBox_AfterUpdate()'entered "data" then enter For Each nName In What do I put here ???? Me.LeftBox.AddItem (nName.What do I put here ???) Next nName end sub Thanks Chris |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Answers to questions posing more questions in a workbook | Excel Worksheet Functions | |||
View Questions and Answer to questions I created | Excel Discussion (Misc queries) | |||
Questions about Forms & Controls | Excel Discussion (Misc queries) | |||
RefEdits and normal forms / forms in a DLL | Excel Programming | |||
Calling Forms from Forms - Exit problems | Excel Programming |