LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
TK TK is offline
external usenet poster
 
Posts: 177
Default ListBox "dynamic fill range"

Hi:

The following code works as expected, but I'm trying to make the
listbox fill range dynamic with the code between
'///////////
...........
...........
'//////////

It works on form's listbox but not a sheet's listbox.


Private Sub ListBox2_Click()

Dim SourceData As Range
Dim Val1 As String
Dim Val2 As String
'////////////////////////////////////
' Dim myRng As Range

' With Worksheets("sheet4")
' Set myRng = .Range("a1:b" & .Cells(.Rows.Count, "A").End(xlUp).Row)
' End With
' ListBox2.ListFillRange = myRng.Address(external:=True)
' Set SourceRange = Range(ListBox2.ListFillRange)

'/////////////////////////////////////

'replace the following line with above
Set SourceRange = Range(ListBox2.ListFillRange)

Val1 = ListBox2.Value
Val2 = SourceRange.Offset(ListBox2.ListIndex, 1).Resize(1, 1).Value

Label1.Caption = Val1 & " " & Val2

If ActiveCell.Column = 1 Then
ActiveCell.Value = Val1
ActiveCell.Offset(0, 3) = Val2
ActiveCell.Offset(1, 0).Activate

Else
MsgBox "Put the CellPointer in the right column"
End If
End Sub

I would appreciate any help or example.


Thanks
TK

 
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
Shortcut to switch from "fill down" to "copy" with mouse drag RJ Dake Excel Discussion (Misc queries) 3 August 13th 09 05:35 PM
More on "Data Range" - Dynamic Range Names Bob Barnes Charts and Charting in Excel 3 March 19th 07 12:09 PM
Dynamic Range with Function "AND" Jeff Excel Discussion (Misc queries) 5 May 24th 06 05:10 PM
How can I make a range "dynamic"? Conan Kelly Excel Worksheet Functions 6 December 27th 05 08:41 PM
Listbox "expand range as list grows" TK Excel Programming 3 September 8th 04 11:57 PM


All times are GMT +1. The time now is 08:35 AM.

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"