Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro to change list box input range based on selection made in another cell

Ok gurus:
Can someone pleeeeaase shed some light on this for me...

I have been asked to create a form in which the user is asked to
select an appropriate General Ledger (GL) account code [via a list
box], based on the nature of the expense they are processing.
Only issue is that there are several legal entities (companies) within
the organisation, each with their own set of [different] GL account
codes (nothing is ever simple around here!)

So I'm hoping to create a macro(?) where when a particular company is
selected (via a validation list), the input range within the
properties of the list box change to reflect the location of the
corresponding codes; the user then makes their selection and the value
is returned to the relevant cell.

EG:

User selects: Company 1
Account Classification List Box diplays set of GL Codes for Company
1...

User selects: Company 2
Account Classification List Box then diplays set of GL Codes for
Company 2

and so on..

there may be an even simpler way to do this??
Really appreciate any guidance here..

Many thanks in advance
Sue :¬)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Macro to change list box input range based on selection made in another cell

Sue,
You may find this helpful
http://www.contextures.com/xlDataVal02.html#Dynamic
Cecil

"Sue" wrote in message
m...
Ok gurus:
Can someone pleeeeaase shed some light on this for me...

I have been asked to create a form in which the user is asked to
select an appropriate General Ledger (GL) account code [via a list
box], based on the nature of the expense they are processing.
Only issue is that there are several legal entities (companies) within
the organisation, each with their own set of [different] GL account
codes (nothing is ever simple around here!)

So I'm hoping to create a macro(?) where when a particular company is
selected (via a validation list), the input range within the
properties of the list box change to reflect the location of the
corresponding codes; the user then makes their selection and the value
is returned to the relevant cell.

EG:

User selects: Company 1
Account Classification List Box diplays set of GL Codes for Company
1...

User selects: Company 2
Account Classification List Box then diplays set of GL Codes for
Company 2

and so on..

there may be an even simpler way to do this??
Really appreciate any guidance here..

Many thanks in advance
Sue :¬)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Macro to change list box input range based on selection made in another cell

Hi there

Thanks for your response...the example you forwarded is heading in the
right direction, although the resulting selection is then made via
another validation list as opposed to a dialog/list box, which is what
we're using.

This is what I currently have down for the dialog box itself.:
_________________________

'SHOW DIALOG1 ACC Classification Code
Sub showDialog1()

If ActiveCell.Column = 4 Then
If ActiveCell.Row < 33 Or ActiveCell.Row 44 Then
resp = MsgBox("Please select the relevant cell in the 'AC
Classification Code' column first.", vbError, "Active Cell Error")
Else
' DialogSheets("ACCCode").ListBoxes("List box 1").ListIndex = 1
resp = DialogSheets("ACCCode").Show
End If
Else
resp = MsgBox("Please select the relevant cell in the 'AC
Classification Code' column first.", vbError, "Active Cell Error")
End If
End Sub

Sub DialogOK1()
ListIndex = DialogSheets("ACCCode").ListBoxes("List box
4").ListIndex
mytext = DialogSheets("ACCCode").ListBoxes("List box
4").List(ListIndex)
ActiveCell.FormulaR1C1 = Trim(Mid$(mytext, 1, 16))

End Sub
______________________________


At present the information within the list contains both the GL Code
and a description of the code, eg:

5100000000006459 Consultancy Costs

However the formula within the macro trims the information so that
only the GL code is returned. The description is required to allow
someone who is unfamiliar with the code (ie: most staff) to make a
more accurate selection.


What I need to do is make the list change based on the selection made
within the target cell..
I think it starts something list this..
_______________________________

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 17 And Target.Column = 6 Then
Select Case Target.Value

[This is where it gets messy - what I want it to do is:
If Case = "TECHNOLOGY" then change source to range "'Sheet1!A:A")]???

Not sure what comes next..
Hope this makes sense..

Cheers again
Sue



"Cecilkumara Fernando" <cekufdo@sltnetDOTlk wrote in message ...
Sue,
You may find this helpful
http://www.contextures.com/xlDataVal02.html#Dynamic
Cecil

"Sue" wrote in message
m...
Ok gurus:
Can someone pleeeeaase shed some light on this for me...

I have been asked to create a form in which the user is asked to
select an appropriate General Ledger (GL) account code [via a list
box], based on the nature of the expense they are processing.
Only issue is that there are several legal entities (companies) within
the organisation, each with their own set of [different] GL account
codes (nothing is ever simple around here!)

So I'm hoping to create a macro(?) where when a particular company is
selected (via a validation list), the input range within the
properties of the list box change to reflect the location of the
corresponding codes; the user then makes their selection and the value
is returned to the relevant cell.

EG:

User selects: Company 1
Account Classification List Box diplays set of GL Codes for Company
1...

User selects: Company 2
Account Classification List Box then diplays set of GL Codes for
Company 2

and so on..

there may be an even simpler way to do this??
Really appreciate any guidance here..

Many thanks in advance
Sue :¬)

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 93
Default Macro to change list box input range based on selection made in another cell

Sue,
Without seen the workbook its bit difficult but as the example you can name
the range you want to get in to the list box exactly to the target cell
value and use the indirect function
say your target cell value is "TECHNOLOGY" then name the source range say
Sheet1A1:A20 as "TECHNOLOGY" and when you use =Indirect(TECHNOLOGY) the
function will get the range Sheet1A1:A20,
You may send a sample workbook to

regards,
Cecil

"Sue" wrote in message
om...
Hi there

Thanks for your response...the example you forwarded is heading in the
right direction, although the resulting selection is then made via
another validation list as opposed to a dialog/list box, which is what
we're using.

This is what I currently have down for the dialog box itself.:
_________________________

'SHOW DIALOG1 ACC Classification Code
Sub showDialog1()

If ActiveCell.Column = 4 Then
If ActiveCell.Row < 33 Or ActiveCell.Row 44 Then
resp = MsgBox("Please select the relevant cell in the 'AC
Classification Code' column first.", vbError, "Active Cell Error")
Else
' DialogSheets("ACCCode").ListBoxes("List box 1").ListIndex = 1
resp = DialogSheets("ACCCode").Show
End If
Else
resp = MsgBox("Please select the relevant cell in the 'AC
Classification Code' column first.", vbError, "Active Cell Error")
End If
End Sub

Sub DialogOK1()
ListIndex = DialogSheets("ACCCode").ListBoxes("List box
4").ListIndex
mytext = DialogSheets("ACCCode").ListBoxes("List box
4").List(ListIndex)
ActiveCell.FormulaR1C1 = Trim(Mid$(mytext, 1, 16))

End Sub
______________________________


At present the information within the list contains both the GL Code
and a description of the code, eg:

5100000000006459 Consultancy Costs

However the formula within the macro trims the information so that
only the GL code is returned. The description is required to allow
someone who is unfamiliar with the code (ie: most staff) to make a
more accurate selection.


What I need to do is make the list change based on the selection made
within the target cell..
I think it starts something list this..
_______________________________

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Row = 17 And Target.Column = 6 Then
Select Case Target.Value

[This is where it gets messy - what I want it to do is:
If Case = "TECHNOLOGY" then change source to range "'Sheet1!A:A")]???

Not sure what comes next..
Hope this makes sense..

Cheers again
Sue



"Cecilkumara Fernando" <cekufdo@sltnetDOTlk wrote in message

...
Sue,
You may find this helpful
http://www.contextures.com/xlDataVal02.html#Dynamic
Cecil

"Sue" wrote in message
m...
Ok gurus:
Can someone pleeeeaase shed some light on this for me...

I have been asked to create a form in which the user is asked to
select an appropriate General Ledger (GL) account code [via a list
box], based on the nature of the expense they are processing.
Only issue is that there are several legal entities (companies) within
the organisation, each with their own set of [different] GL account
codes (nothing is ever simple around here!)

So I'm hoping to create a macro(?) where when a particular company is
selected (via a validation list), the input range within the
properties of the list box change to reflect the location of the
corresponding codes; the user then makes their selection and the value
is returned to the relevant cell.

EG:

User selects: Company 1
Account Classification List Box diplays set of GL Codes for Company
1...

User selects: Company 2
Account Classification List Box then diplays set of GL Codes for
Company 2

and so on..

there may be an even simpler way to do this??
Really appreciate any guidance here..

Many thanks in advance
Sue :¬)



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
List box change values based on selection Cam Excel Discussion (Misc queries) 0 March 17th 08 01:38 PM
run macro with input msg based on cell input Janelle S Excel Discussion (Misc queries) 0 January 20th 08 05:23 AM
How do I change the format of a cell based on what I input? Husker87 Excel Worksheet Functions 8 August 19th 05 10:45 PM
limit cell list selection based on the selection of another list lorraine Excel Worksheet Functions 2 December 14th 04 08:17 PM
Macro to input formula in range based on another range Peter Atherton Excel Programming 0 October 9th 03 12:47 AM


All times are GMT +1. The time now is 04:14 PM.

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"