Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using IF, Then with rowsource?

Does anybody know why i can't do this

If ShN 4 And ShN < 9 Then
shHeight1.Enabled = False
shHeight1.BackColor = &HA49597
ShHang1.RowSource = "Sheet1!B50:B56"
Else
shHeight1.Enabled = False
shHeight1.BackColor = &HF9F8EC
ShHang1.RowSource = Sheets("Window Styles").Range("C50:C57")
End If

Hope somebody can shed some light for me.
Thanks
CA

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Using IF, Then with rowsource?

You don't say what the problem is. If it is this line

ShHang1.RowSource = Sheets("Window Styles").Range("C50:C57")

try

ShHang1.RowSource = "'" & Sheets("Window Styles").Name & "'!" &
Sheets("Window Styles").Range("C50:C57").Address

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"CAA " wrote in message
...
Does anybody know why i can't do this

If ShN 4 And ShN < 9 Then
shHeight1.Enabled = False
shHeight1.BackColor = &HA49597
ShHang1.RowSource = "Sheet1!B50:B56"
Else
shHeight1.Enabled = False
shHeight1.BackColor = &HF9F8EC
ShHang1.RowSource = Sheets("Window Styles").Range("C50:C57")
End If

Hope somebody can shed some light for me.
Thanks
CAA


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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using IF, Then with rowsource?

Sorry Bob
However a guru like yourself can spot these problems withou
explanation ;-)

The problem was it didn't populate my combobox.
I tried your piece of code and still nothing, so I trimmed out th
first bit and then realised that an erlier attempt only needed th
.Address at the end. Which after trimming yours was exactly what
needed.

I need to read more about the references cells, previously I had gotte
away with just "Sheet1!B50:B56" but had never ttried within an i
statement to set it at runtime, quirky stuff.

Thanks alot for your help, my day has just become lighter.
CA

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Using IF, Then with rowsource?

The Rowsource is a string property and you were setting it to a range. This
part, Sheet1!B50:B56" , is a nice simple string, when using a reference to
another part of a worksheet it is not so obvious is it.

Anyway, glad you are sorted now.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"CAA " wrote in message
...
Sorry Bob
However a guru like yourself can spot these problems without
explanation ;-)

The problem was it didn't populate my combobox.
I tried your piece of code and still nothing, so I trimmed out the
first bit and then realised that an erlier attempt only needed the
Address at the end. Which after trimming yours was exactly what I
needed.

I need to read more about the references cells, previously I had gotten
away with just "Sheet1!B50:B56" but had never ttried within an if
statement to set it at runtime, quirky stuff.

Thanks alot for your help, my day has just become lighter.
CAA


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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Using IF, Then with rowsource?

I find this style easier to type and read:

ShHang1.RowSource _
= Sheets("Window Styles").Range("C50:C57").address(external:=true)

Bob Phillips wrote:

You don't say what the problem is. If it is this line

ShHang1.RowSource = Sheets("Window Styles").Range("C50:C57")

try

ShHang1.RowSource = "'" & Sheets("Window Styles").Name & "'!" &
Sheets("Window Styles").Range("C50:C57").Address

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"CAA " wrote in message
...
Does anybody know why i can't do this

If ShN 4 And ShN < 9 Then
shHeight1.Enabled = False
shHeight1.BackColor = &HA49597
ShHang1.RowSource = "Sheet1!B50:B56"
Else
shHeight1.Enabled = False
shHeight1.BackColor = &HF9F8EC
ShHang1.RowSource = Sheets("Window Styles").Range("C50:C57")
End If

Hope somebody can shed some light for me.
Thanks
CAA


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


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using IF, Then with rowsource?

Cheers Dave

That's nearly exactly as i've put it, however i don't have a clue wha
the (external = true) is for, I looked it up and found it mean
external referance.
I don't know what that means for excel, I use Autocad and an externa
referance is part of the drawing that is a copy of another drawing
when the other is updated then the changes are reflected in you
current drawing, is this similar for Excel?


CA

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

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Using IF, Then with rowsource?

Try this:

with activesheet
msgbox .range("a1").address
msgbox .range("a1").address(0,0)
msgbox .range("a1").address(external:=true)
end with

And you'll see what it does.



"CAA <" wrote:

Cheers Dave

That's nearly exactly as i've put it, however i don't have a clue what
the (external = true) is for, I looked it up and found it means
external referance.
I don't know what that means for excel, I use Autocad and an external
referance is part of the drawing that is a copy of another drawing,
when the other is updated then the changes are reflected in your
current drawing, is this similar for Excel?

CAA

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


--

Dave Peterson

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Using IF, Then with rowsource?

Address returns a string showing the address of the range. The optional
arguments ajdust the appearance of that address.

by default it is

With Workbooks("Book1.xls")
Set rng = .Worksheets("Sheet5").Range("B9:C12")
End With

rng.Address would return
$B$9:$C$12

rng.Address(external:=True) would return
[Book1.xls]Sheet5!$B$9:$C$12

So External really means fully qualified - the thought being that you
wouldn't need that information unless the reference was to a workbook
external to the current one.

--
Regards,
Tom Ogilvy


"CAA " wrote in message
...
Cheers Dave

That's nearly exactly as i've put it, however i don't have a clue what
the (external = true) is for, I looked it up and found it means
external referance.
I don't know what that means for excel, I use Autocad and an external
referance is part of the drawing that is a copy of another drawing,
when the other is updated then the changes are reflected in your
current drawing, is this similar for Excel?


CAA


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



  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using IF, Then with rowsource?

Well, I've learnt quite a bit And all is very handy stuff

As it turned out Bob gave me the right answer for my situation th
fisrt time round.
I had trimmed off the first part and because my form has model=Fals
whenever i changed worksheets the combobox rowsource changed.
Thanks alot for the help guys
CA

--
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
???Help??? Userform.Listbox.rowsource = ??? Steve Sparti Excel Discussion (Misc queries) 0 March 1st 06 09:44 PM
RowSource Problem Todd Huttenstine[_2_] Excel Programming 1 January 20th 04 04:09 AM
RowSource in ListBox aet-inc[_2_] Excel Programming 1 December 3rd 03 12:41 AM
Dropdown Rowsource Aechelon[_7_] Excel Programming 1 October 24th 03 11:48 PM
listbox rowsource Christy[_2_] Excel Programming 4 September 20th 03 11:44 PM


All times are GMT +1. The time now is 01:58 PM.

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"