Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Range Reference in Visual Basic

Hi:

I have the following worksheet based macro in VBA:


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$F$5" Then
Run "buttonchange"
End If
End Sub

I want to expand the target address to F5 OR F6, and have no idea how to do it. Whatever I
try $F$5:$F$6, $F$5 OR $F$6 or a myriad of variations around that come up with a compile
error OR don't work!

Anyone got any thoughts on this?

Regards
John Baker
  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Range Reference in Visual Basic

try

If Target.Address = "$F$5" OR Target.Address = "$F$6" Then
Run "buttonchange"
End If

regards ojv
-----Original Message-----
Hi:

I have the following worksheet based macro in VBA:


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$F$5" Then
Run "buttonchange"
End If
End Sub

I want to expand the target address to F5 OR F6, and

have no idea how to do it. Whatever I
try $F$5:$F$6, $F$5 OR $F$6 or a myriad of variations

around that come up with a compile
error OR don't work!

Anyone got any thoughts on this?

Regards
John Baker
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22,906
Default Range Reference in Visual Basic

John

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$F$5" Or Target.Address = "$F$6" Then
Run "buttonchange"
End If
End Sub

Gord Dibben XL2002

On Sat, 22 Nov 2003 13:18:12 GMT, John Baker wrote:

Hi:

I have the following worksheet based macro in VBA:


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$F$5" Then
Run "buttonchange"
End If
End Sub

I want to expand the target address to F5 OR F6, and have no idea how to do it. Whatever I
try $F$5:$F$6, $F$5 OR $F$6 or a myriad of variations around that come up with a compile
error OR don't work!

Anyone got any thoughts on this?

Regards
John Baker


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 690
Default Range Reference in Visual Basic

Just to give another option...

Private Sub Worksheet_Change(ByVal Target As Range)
Select Case Target.Address(False, False)
Case "F5", "F6"
Run "buttonchange"
End Select
End Sub

--
Dana DeLouis
Using Windows XP & Office XP
= = = = = = = = = = = = = = = = =


"John Baker" wrote in message
...
Hi:

I have the following worksheet based macro in VBA:


Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$F$5" Then
Run "buttonchange"
End If
End Sub

I want to expand the target address to F5 OR F6, and have no idea how to

do it. Whatever I
try $F$5:$F$6, $F$5 OR $F$6 or a myriad of variations around that come up

with a compile
error OR don't work!

Anyone got any thoughts on this?

Regards
John Baker



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
If Range not equal to zero in Visual Basic If/Then statement Clinton W Excel Discussion (Misc queries) 3 May 2nd 09 11:17 PM
Visual Basic to reference value in Excel cell Raymond[_4_] Excel Programming 1 October 28th 03 08:24 PM
Visual Basic Range variable Andrew Johnson Excel Programming 2 August 25th 03 05:18 PM
Visual basic to step through range and store a value based on text attribute value. Bob Phillips[_5_] Excel Programming 1 August 8th 03 02:50 PM
Visual basic to step through range and store a value based on text attribute value. Bob Kilmer Excel Programming 0 August 7th 03 09:46 PM


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