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

I am using a listbox in sheet2, I want to refernce a range in sheet1,
have the following statement:

Private Sub ListBox1_Click()

ListBox1.ListFillRange = Worksheets("Sheet1").Range("A4:A14").Address

End Sub


For some reason it is not showing any values. Anyone know why?
Thanks

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 599
Default reference sheets

MaxRott

It's because the Address property of a range does not identify which sheet
it's on. These two line produce the exact same result

Sheets("Sheet1").Range("A1").Address
Sheets("Sheet2").Range("A1").Address

If you know the sheet and the range, then just assign a string to the
ListFillRange

ListBox1.ListFillRange = "Sheet1!A4:A14"

If you want to use address, then you it would look like this

ListBox1.ListFillRange = Worksheets("Sheet1").Name & "!" &
Worksheets("Sheet1").Range("A4:A14").Address

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"MaxRott" wrote in message
...
Forgot to mention.....when I use data on the same sheet I can use:

Private Sub ListBox1_Click()

ListBox1.ListFillRange = ActiveSheet.Range("A4:A14").Address

End Sub

and it works fine.


---
Message posted from http://www.ExcelForum.com/



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
Reference Sheets in a Vlookup Thomas Roos Excel Worksheet Functions 4 November 13th 08 06:40 PM
Reference sheets KKcags Excel Worksheet Functions 1 May 7th 08 09:20 PM
Cross Reference between sheets JP Excel Worksheet Functions 2 May 14th 06 01:36 PM
in VBA Sheets("mysheet").Copy Befo=Sheets(1) how do i get a reference to the newly created copy of this sheet? Daniel Excel Worksheet Functions 1 July 6th 05 09:57 PM
reference sheets MaxRott[_2_] Excel Programming 0 December 12th 03 08:09 PM


All times are GMT +1. The time now is 03:17 AM.

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

About Us

"It's about Microsoft Excel"