Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Worksheet selectionChange problem

I am trying to run a macro called hardware when the user clicks in cell C14.
I am new to VB in Excel, but use VB in Access.

When I run the following code in debug mode, I can see that it is skipping
the instructions after "then" in the if statement even when the target
address is $C$14. What am I missing?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$c$14" Then
MsgBox "Hardware"
End If
End Sub

Thanks
Sammie
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 92
Default Worksheet selectionChange problem

Sammie

Try this

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Not Application.Intersect(Range("$c$14"), Target) Is Nothing Then

MsgBox "Hardware"
End If
End Sub


hth
Mark

"Sammie" wrote:

I am trying to run a macro called hardware when the user clicks in cell C14.
I am new to VB in Excel, but use VB in Access.

When I run the following code in debug mode, I can see that it is skipping
the instructions after "then" in the if statement even when the target
address is $C$14. What am I missing?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$c$14" Then
MsgBox "Hardware"
End If
End Sub

Thanks
Sammie

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Worksheet selectionChange problem

When using this code:

If Target.Address = "$c$14" Then

I got the same result that you did. But using this:

If Target.Address = "$C$14" Then

It worked fine.



"Sammie" wrote:

I am trying to run a macro called hardware when the user clicks in cell C14.
I am new to VB in Excel, but use VB in Access.

When I run the following code in debug mode, I can see that it is skipping
the instructions after "then" in the if statement even when the target
address is $C$14. What am I missing?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$c$14" Then
MsgBox "Hardware"
End If
End Sub

Thanks
Sammie

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Worksheet selectionChange problem

Thanks. Your code does read the then statement, however, the msgbox doesn't
run the macro. I get a dialog box that says "hardware". Can you help?

"Mark Dullingham" wrote:

Sammie

Try this

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Not Application.Intersect(Range("$c$14"), Target) Is Nothing Then

MsgBox "Hardware"
End If
End Sub


hth
Mark

"Sammie" wrote:

I am trying to run a macro called hardware when the user clicks in cell C14.
I am new to VB in Excel, but use VB in Access.

When I run the following code in debug mode, I can see that it is skipping
the instructions after "then" in the if statement even when the target
address is $C$14. What am I missing?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$c$14" Then
MsgBox "Hardware"
End If
End Sub

Thanks
Sammie

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Worksheet selectionChange problem

Wow! As simple as using upper case for the reference! You learn something
every day. Thanks.
Your code does read the then statement, however, the msgbox doesn't run the
macro. I get a dialog box that says "hardware". Can you help?
Sammie
"JLGWhiz" wrote:

When using this code:

If Target.Address = "$c$14" Then

I got the same result that you did. But using this:

If Target.Address = "$C$14" Then

It worked fine.



"Sammie" wrote:

I am trying to run a macro called hardware when the user clicks in cell C14.
I am new to VB in Excel, but use VB in Access.

When I run the following code in debug mode, I can see that it is skipping
the instructions after "then" in the if statement even when the target
address is $C$14. What am I missing?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$c$14" Then
MsgBox "Hardware"
End If
End Sub

Thanks
Sammie



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Worksheet selectionChange problem

The msgbox isn't ever going to run a macro.

Maybe you want to call the macro after the msgbox:

MsgBox "Hardware"
Call whateverprocedureyouaretryingtorun

?????

Sammie wrote:

Wow! As simple as using upper case for the reference! You learn something
every day. Thanks.
Your code does read the then statement, however, the msgbox doesn't run the
macro. I get a dialog box that says "hardware". Can you help?
Sammie
"JLGWhiz" wrote:

When using this code:

If Target.Address = "$c$14" Then

I got the same result that you did. But using this:

If Target.Address = "$C$14" Then

It worked fine.



"Sammie" wrote:

I am trying to run a macro called hardware when the user clicks in cell C14.
I am new to VB in Excel, but use VB in Access.

When I run the following code in debug mode, I can see that it is skipping
the instructions after "then" in the if statement even when the target
address is $C$14. What am I missing?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$c$14" Then
MsgBox "Hardware"
End If
End Sub

Thanks
Sammie


--

Dave Peterson
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Worksheet selectionChange problem



"Dave Peterson" wrote:

The msgbox isn't ever going to run a macro.

Maybe you want to call the macro after the msgbox:

MsgBox "Hardware"
Call whateverprocedureyouaretryingtorun

?????

Sammie wrote:

Wow! As simple as using upper case for the reference! You learn something
every day. Thanks.
Your code does read the then statement, however, the msgbox doesn't run the
macro. I get a dialog box that says "hardware". Can you help?
Sammie
"JLGWhiz" wrote:

When using this code:

If Target.Address = "$c$14" Then

I got the same result that you did. But using this:

If Target.Address = "$C$14" Then

It worked fine.



"Sammie" wrote:

I am trying to run a macro called hardware when the user clicks in cell C14.
I am new to VB in Excel, but use VB in Access.

When I run the following code in debug mode, I can see that it is skipping
the instructions after "then" in the if statement even when the target
address is $C$14. What am I missing?

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$c$14" Then
MsgBox "Hardware"
End If
End Sub

Thanks
Sammie


--

Dave Peterson
So simple. Thanks!

Sammie
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
Button Visibility / Selectionchange Problem mastermind Excel Programming 3 January 11th 07 10:08 PM
Worksheet SelectionChange Event mjack003 Excel Discussion (Misc queries) 2 May 8th 06 08:35 PM
Worksheet SelectionChange event [email protected] Excel Programming 6 June 24th 05 12:51 AM
selectionchange problem micher Excel Programming 2 January 27th 04 07:15 PM
SelectionChange problem Micher Excel Programming 0 January 23rd 04 10:26 PM


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