Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Choose box, put cell contents, update

I have a drop down box that user chooses from this in turn place a 1, 2, 3 in
L11. At this point I want the code below to run placing the result in G6.
However, I have to physically go to cell L11, F2, enter to make it update.
How do I get G6 to update automatically after selection of choose box.

Thanks

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$L$11" And Target.Count = 1 Then
If (Target.Value) = "1" Then
Range("G6") = "Cat"
End If
End If
If Target.Address = "$L$11" And Target.Count = 1 Then
If (Target.Value) = "2" Then
Range("G6") = "Dog"
End If
End If
If Target.Address = "$L$11" And Target.Count = 1 Then
If (Target.Value) = "3" Then
Range("G6") = "Fish"
End If
End If
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Choose box, put cell contents, update

Hi,

Don't use the worksheet change event use the dropdown change event instead.
Right click it and use this simplified code

Sub DropDown1_Change()
Select Case Sheets("Sheet1").Range("L11")
Case Is = 1
Range("G6") = "Cat"
Case Is = 2
Range("G6") = "Dog"
Case Is = 3
Range("G6") = "Fish"
End Select
End Sub

Mike

"deeds" wrote:

I have a drop down box that user chooses from this in turn place a 1, 2, 3 in
L11. At this point I want the code below to run placing the result in G6.
However, I have to physically go to cell L11, F2, enter to make it update.
How do I get G6 to update automatically after selection of choose box.

Thanks

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$L$11" And Target.Count = 1 Then
If (Target.Value) = "1" Then
Range("G6") = "Cat"
End If
End If
If Target.Address = "$L$11" And Target.Count = 1 Then
If (Target.Value) = "2" Then
Range("G6") = "Dog"
End If
End If
If Target.Address = "$L$11" And Target.Count = 1 Then
If (Target.Value) = "3" Then
Range("G6") = "Fish"
End If
End If
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Choose box, put cell contents, update


the macro is being called twice because when you change G6 is causes a
2nd event of the macro to occur. disableEvent should solve the problem.
I also made some improvements to the code.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$L$11" And Target.Count = 1 Then
Application.EnableEvents = False
Select Case Target.Value

Case 1:
Range("G6") = "Cat"
Case 2:
Range("G6") = "Dog"
Case 3:
Range("G6") = "Fish"
End Select
Application.EnableEvents = False
End If
End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=149424

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
Update cell contents based on worksheet name PJ Excel Discussion (Misc queries) 1 August 8th 07 10:37 PM
Macro to update contents of cell Louise Excel Programming 4 December 2nd 05 09:30 PM
Can I use cell contents to update footers in excel? GregW Excel Discussion (Misc queries) 2 August 15th 05 06:49 PM
How do I update contents of activeX combobox? Paul Silverman Excel Programming 1 September 20th 04 01:54 PM
Update - Include cell contents in filename automatically Bryan Linton Excel Programming 1 September 3rd 04 07:08 PM


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