Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Auto Editing the Row source.


Hi,
I have a combobox in the userform. And I have a data range: (A2:A40).

I want the dropdown to read the range A2:A40.

That will help the user choose from the dropown list.

Now what if the range gets smaller or larger. Do I have to change the
"Row Source" Everytime a change takes place?

I mean A40 is the destination, but it might be less in the future so
how do I
fix: A2:A40 once and for all.


Thanks,
Nawaf


--
countryfan_nt
------------------------------------------------------------------------
countryfan_nt's Profile: http://www.excelforum.com/member.php...o&userid=11051
View this thread: http://www.excelforum.com/showthread...hreadid=386366

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Auto Editing the Row source.

Hi,
Try this:

Private Sub UserForm_Initialize()
lr = Cells(Rows.Count, "A").End(xlUp).Row ' Last row
ComboBox1.RowSource = "a2:a" & lr
End Sub

HTH

"countryfan_nt" wrote:


Hi,
I have a combobox in the userform. And I have a data range: (A2:A40).

I want the dropdown to read the range A2:A40.

That will help the user choose from the dropown list.

Now what if the range gets smaller or larger. Do I have to change the
"Row Source" Everytime a change takes place?

I mean A40 is the destination, but it might be less in the future so
how do I
fix: A2:A40 once and for all.


Thanks,
Nawaf


--
countryfan_nt
------------------------------------------------------------------------
countryfan_nt's Profile: http://www.excelforum.com/member.php...o&userid=11051
View this thread: http://www.excelforum.com/showthread...hreadid=386366


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Auto Editing the Row source.


Thanks,

But, When I run the code I get "Compile error: Varriable not defined".
And "lr =" is highlighted. What Am I missing? Or what did I do wrong?

Nawaf


--
countryfan_nt
------------------------------------------------------------------------
countryfan_nt's Profile: http://www.excelforum.com/member.php...o&userid=11051
View this thread: http://www.excelforum.com/showthread...hreadid=386366

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default Auto Editing the Row source.

Add "Dim lr as Long" to the macro as I take it you have (correctly) an
"Option explicit" statement in you code.

HTH

"countryfan_nt" wrote:


Thanks,

But, When I run the code I get "Compile error: Varriable not defined".
And "lr =" is highlighted. What Am I missing? Or what did I do wrong?

Nawaf


--
countryfan_nt
------------------------------------------------------------------------
countryfan_nt's Profile: http://www.excelforum.com/member.php...o&userid=11051
View this thread: http://www.excelforum.com/showthread...hreadid=386366


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Auto Editing the Row source.


Ok 2 more questions:

1: Do I need to specify the sheet name in the code because A2 is vague
without mentioning the sheet name. The sheet name is "LookupLists".

2: Where do I place the code. I mean should it be inside the comboBox
"View Code"


--
countryfan_nt
------------------------------------------------------------------------
countryfan_nt's Profile: http://www.excelforum.com/member.php...o&userid=11051
View this thread: http://www.excelforum.com/showthread...hreadid=386366

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
Pivot tables - Editing the data source shared by multiple pivot ta sankat Excel Discussion (Misc queries) 1 April 22nd 10 03:05 PM
stop excel from auto editing my numbers HoganD87 Excel Discussion (Misc queries) 5 September 18th 07 05:58 PM
to turn off Auto editing of cell anil Excel Discussion (Misc queries) 3 April 20th 07 04:00 AM
Editing Source Data in Charts F. Lawrence Kulchar Charts and Charting in Excel 1 November 5th 06 03:18 PM
MSQuery editing source data? Dave H Excel Discussion (Misc queries) 0 April 21st 06 04:41 PM


All times are GMT +1. The time now is 12:28 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"