|
-
May 17th, 2005, 09:06 AM
#1
Thread Starter
New Member
vba excel => passing a range
Hello,
I have one simple worksheet and one simple command button on it.
In the code of the command button i specify a software coded range and and by clicking the command button, the worksheet_change function needs to explicitly executed with this range.
However, there seems to be an error by passing the range that i specified in the code of the command button.. I get the error 'runtime error 424', 'object required'.
can anyone tell me what's wrong with this simple piece of code .
Code:
Public Sub CommandButton1_Click()
Dim r As Range
Set r = Range("A1:B5")
Worksheet_Change (r)
End Sub
Public Sub Worksheet_Change(ByVal Target As Range)
MsgBox Target.Cells.Count
End Sub
thanks in advance
-
May 17th, 2005, 10:19 AM
#2
New Member
Re: vba excel => passing a range
Try to "call" the event
=> Call Worksheet_Change(r)
-
May 17th, 2005, 02:05 PM
#3
Fanatic Member
Re: vba excel => passing a range
I believe the following will also work:
VBAhack
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|