LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 157
Default Pass variables to Worksheet_SelectionChange

I have the following code which works well as it stands. My problem is that
I need to vary the range depending on conditions set in other code.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
'----- ENABLE TICKS IN RELEVANT BOXES -----
Application.EnableEvents = False
On Error GoTo sub_exit
If Not Intersect(Target, Worksheets("Room").Range("P11:T39")) Is Nothing
Then
With Target
If .Value = Chr(252) Then
.Value = ""
Else
.Value = Chr(252)
.Font.Name = "Wingdings"
End If
End With
End If
sub_exit:
Application.EnableEvents = True
End Sub


I've tried changing the first line to Private Sub
Worksheet_SelectionChange(ByVal Target As Range, r, c) to pass row and
column but this causes a problem earlier in my code with an apparently
unrelated instruction.

To explain further, I have a form which the enables the user to select from
a number of lists using comboboxes. Once the comboboxes are populated, the
user presses a commandbutton.

Private Sub CommandButton1_Click()
With Worksheets("Room")
.Unprotect
.Range("F3") = ComboBox1.Text
.Range("W3") = ComboBox2.Text
.Range("I2") = CDate(TextBox1.Value)
.Visible = True
.Activate
.Range("A1").Select
.Protect
End With
Worksheets("Lookup").Visible = False
UserForm1.Hide
Call Worksheets("Room").UserForm_Reaction
With ActiveWindow
.WindowState = xlMaximized
End With
Worksheets("Room").Range("F2").Select
End Sub

The line causing the problem is .Unprotect but the code runs perfectly with
the original Worksheet_SelectionChange line.

Perhaps I'm expecting the impossible in trying to make the target range
dynamic.

Any ideas?

--
Ian
--


 
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 to pass variables as arguments of a function Excel-craze Excel Worksheet Functions 1 August 12th 09 11:48 AM
Application.Run and pass variables to Sub Barb Reinhardt Excel Programming 2 September 26th 08 02:35 PM
Pass variables value to Shell wpw3 Excel Programming 0 March 7th 05 03:55 PM
Defining Variables that pass to other Subs JasonSelf[_14_] Excel Programming 2 August 11th 04 08:57 PM
can variables pass values Don[_11_] Excel Programming 3 November 1st 03 04:50 PM


All times are GMT +1. The time now is 08:25 AM.

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"