Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Execute Events Based Upon Selected Cell

I noticed that the address are locked (i.e. $H$2) as opposed to unlocked
(i.e. "H2"). Is there a reason for that difference? And how would I change
the code to unlock the address such that I can support H2, H8, H12, ...?
Thanks again.

D. Parker

"Jim Thomlinson" wrote:

It is a more explicit declaration. In this case it really will not make any
difference whatsoever. Usually the more explicit the declaration the better,
but in this case it doesn't make any difference... If there were to items
Excel and another that could both have ranges, then you would need to
explcitle declate what type of range you wanted to use...

HTH

"D.Parker" wrote:


What is the difference between using Excel.Range and just Range in the
Worksheet_SelectionChange sub? Thank you.

Kind regards,

D.Parker

"Jim Thomlinson" wrote:

Target is the cell you just selected, so here is some code for you...

Option Explicit

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Select Case Target.Address
Case "$H$2"
Target.Value = "X"
Case "$I$2"
Target.Value = "X"
Case "$J$2"
Target.Value = "X"
End Select
End Sub

HTH

"D.Parker" wrote:

I am trying to program code to execute specific conditions if certain cells
are selected. I am working within my worksheet and with the
Worksheet_SelectionChange (ByVal Target As Excel.Range) subroutine. I have
tried using the AcitveCell.Address per the following example:

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

If ActiveCell.Address = Range("H2") Then
'Range("H2").Value = "X"
End If

End Sub

What has generally happened through my numerous iterations is that the "X"
is never entered into the selected cell or any other cell for that matter.

The goal is to have "X" entered into cell H2 only if cell H2 is selected.
Your assistance is highly appreciated. Any advice or recommendations you may
have is again well appreciated.

Kind regards,

D.Parker




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
Highlight the cell based on selected value Max Excel Worksheet Functions 2 July 1st 09 09:57 AM
How to change cell text based on another selected cell? jjh Excel Discussion (Misc queries) 1 July 6th 06 01:14 PM
How do I execute a macro based on the value of a cell in Excel? brettopp Excel Discussion (Misc queries) 12 June 17th 06 01:27 AM
Application level events no longer execute R Avery Excel Programming 1 June 4th 04 01:21 AM
Execute a Macro when specific value is selected in a Range Kevin Excel Programming 3 November 21st 03 03:54 AM


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