Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Selection change: How to run a Macro

Hello:
I would appreciate help with the following:

Cell A1 has a dropdown list (Data, Validation feature) which allows user to
select from one of three choice.

Based on the value in cell A1, cells B1, B2, B3 have different values. I
have written a macro to enter those specific values in cells B1:B3 based on
the value in cell A1.

What kind of code do I need in the SelectionChange to be able to populate
B1:B3 with the correct values based on user selection in cell A1

TIA


--
Maria


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,885
Default Selection change: How to run a Macro

Hi Maria
do you really want an event procedure. Thís could also be achieved with
formulas (e.g. IF or VLOOKUP)
but you may try the following code:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Intersect(Target, Me.Range("A1")) Is Nothing Then Exit Sub
On Error GoTo CleanUp:
With Target
Select Case .Value
Case 1 'change this according to your needs
cells(1,2).value = "value1-1"
cells(2,2).value = "value1-2"
cells(3,2).value = "value1-3"
Case 2
cells(1,2).value = "value2-1"
cells(2,2).value = "value2-2"
cells(3,2).value = "value2-3"
Case 3
cells(1,2).value = "value3-1"
cells(2,2).value = "value3-2"
cells(3,2).value = "value3-3"
End Select
End With
CleanUp:
Application.EnableEvents = True
End Sub



--
Regards
Frank Kabel
Frankfurt, Germany

Maria wrote:
Hello:
I would appreciate help with the following:

Cell A1 has a dropdown list (Data, Validation feature) which allows
user to select from one of three choice.

Based on the value in cell A1, cells B1, B2, B3 have different
values. I have written a macro to enter those specific values in
cells B1:B3 based on the value in cell A1.

What kind of code do I need in the SelectionChange to be able to
populate B1:B3 with the correct values based on user selection in
cell A1

TIA


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
How can run a macro ( call a macro) on selection of any filtercriteria? [email protected] Excel Worksheet Functions 7 February 20th 09 12:34 AM
Change row selection Farrel Excel Worksheet Functions 7 July 13th 05 06:58 PM
Macro to only change selection Del[_3_] Excel Programming 3 December 16th 03 04:30 PM
Worksheet Selection Change DEFJ Excel Programming 4 November 15th 03 11:45 PM
Selection Change question Chip Pearson Excel Programming 3 August 14th 03 05:16 PM


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