PC Review


Reply
Thread Tools Rate Thread

Cell drives combo box change

 
 
=?Utf-8?B?SmVyZW15?=
Guest
Posts: n/a
 
      3rd Jul 2007
I'm trying to get a combo box to change in reference to a cell. For example:

Say Sheet 1, B6 has a ID value of 1. I want the macro to read that there is
a 1 there, then go to sheet 2 where the combo box list is located (K6 is the
text, L6 is the ID value 1 associated with it), then have the combo box on
sheet 3 change to the selection.

Any ideas? I've tried some various things and am not getting very far.

Thanks.
 
Reply With Quote
 
 
 
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      3rd Jul 2007
Dim cell as Range, rng as Range, res as Variant
set cell = Worksheets("Sheet1").Range("B6")
With worksheets("Sheet2")
set rng = .Range("L1",.Range("L1").End(xldown))
End with
res = application.Match(cell,rng,0)
if not iserror(res) then
Combobox1.Value = rng(res).offset(0,-1).Value
End if

--
Regards,
Tom Ogilvy


"Jeremy" wrote:

> I'm trying to get a combo box to change in reference to a cell. For example:
>
> Say Sheet 1, B6 has a ID value of 1. I want the macro to read that there is
> a 1 there, then go to sheet 2 where the combo box list is located (K6 is the
> text, L6 is the ID value 1 associated with it), then have the combo box on
> sheet 3 change to the selection.
>
> Any ideas? I've tried some various things and am not getting very far.
>
> Thanks.

 
Reply With Quote
 
=?Utf-8?B?SmVyZW15?=
Guest
Posts: n/a
 
      3rd Jul 2007
hmm, I keep getting an error when I get to the line:

Combobox1.Value = rng(res).offset(0,-1).Value


I put the name of the combo box in place of the "combobox1" in the line.


"Tom Ogilvy" wrote:

> Dim cell as Range, rng as Range, res as Variant
> set cell = Worksheets("Sheet1").Range("B6")
> With worksheets("Sheet2")
> set rng = .Range("L1",.Range("L1").End(xldown))
> End with
> res = application.Match(cell,rng,0)
> if not iserror(res) then
> Combobox1.Value = rng(res).offset(0,-1).Value
> End if
>
> --
> Regards,
> Tom Ogilvy
>
>
> "Jeremy" wrote:
>
> > I'm trying to get a combo box to change in reference to a cell. For example:
> >
> > Say Sheet 1, B6 has a ID value of 1. I want the macro to read that there is
> > a 1 there, then go to sheet 2 where the combo box list is located (K6 is the
> > text, L6 is the ID value 1 associated with it), then have the combo box on
> > sheet 3 change to the selection.
> >
> > Any ideas? I've tried some various things and am not getting very far.
> >
> > Thanks.

 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      3rd Jul 2007
does combobox1 need to be qualified?

Is rng at least in column 2.

Demo'd from the immediate window:

set rng = Range("B1:B10")
Range("B5") = "AA"
res = Application.Match("AA",rng,0)
? rng(res).offset(0,-1).Address
$A$5

so the concept is proven.

Must be an implementation error.

--
Regards,
Tom Ogilvy


"Jeremy" wrote:

> hmm, I keep getting an error when I get to the line:
>
> Combobox1.Value = rng(res).offset(0,-1).Value
>
>
> I put the name of the combo box in place of the "combobox1" in the line.
>
>
> "Tom Ogilvy" wrote:
>
> > Dim cell as Range, rng as Range, res as Variant
> > set cell = Worksheets("Sheet1").Range("B6")
> > With worksheets("Sheet2")
> > set rng = .Range("L1",.Range("L1").End(xldown))
> > End with
> > res = application.Match(cell,rng,0)
> > if not iserror(res) then
> > Combobox1.Value = rng(res).offset(0,-1).Value
> > End if
> >
> > --
> > Regards,
> > Tom Ogilvy
> >
> >
> > "Jeremy" wrote:
> >
> > > I'm trying to get a combo box to change in reference to a cell. For example:
> > >
> > > Say Sheet 1, B6 has a ID value of 1. I want the macro to read that there is
> > > a 1 there, then go to sheet 2 where the combo box list is located (K6 is the
> > > text, L6 is the ID value 1 associated with it), then have the combo box on
> > > sheet 3 change to the selection.
> > >
> > > Any ideas? I've tried some various things and am not getting very far.
> > >
> > > Thanks.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ineed a combo box to change its list dependant on the active cell Atishoo Microsoft Excel Programming 1 25th Apr 2008 09:58 PM
Worksheet change event with cell linked to combo box result Fid Microsoft Excel Programming 5 22nd Dec 2006 08:55 PM
Using linked cell to change value in combo box =?Utf-8?B?ZXVnZW5l?= Microsoft Excel Programming 2 9th May 2006 05:21 PM
Referencing a Sheet and Cell Location in Change Event of Combo Box DoctorV Microsoft Excel Discussion 2 4th Mar 2004 09:18 PM
How do I use a Combo Box to change values in a Cell. Havok Microsoft Excel Programming 4 29th Oct 2003 08:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:09 PM.