PC Review


Reply
Thread Tools Rate Thread

code for command button not work

 
 
=?Utf-8?B?c2ltb24=?=
Guest
Posts: n/a
 
      15th Nov 2006
Hi,
every time compile code get error:

compile error:

procedure declaration does not match description of event or procedure
having the same name

code in commmandbutton1:
Private Sub CommandButton1_Click(ByVal target As Range)

Dim Temp As Variant

If Target.Column = 1 Then
Application.EnableEvents = False
Temp = Split(Target.Value, "^")

Target.Value = Mid(Temp(0), 2)
Target.Offset(0, 1).Value = Temp(1)
Target.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)

Application.EnableEvents = True
End If
End Sub


thanks

 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      15th Nov 2006
Simon,
You cannot create any event declaration you like; it has to be what the
object is expecting.
It is easier to get VBA to generate the stub for you, so add a command
button, then double click it. Excel/VBA will generate the required _Click
outline for you.

You will see that you do not have any arguments, only empty brackets.
Therefore, you need to ActiveCell in you code instead of Target.

NickHK

"simon" <(E-Mail Removed)> wrote in message
news:831B0953-D2F3-441E-98EE-(E-Mail Removed)...
> Hi,
> every time compile code get error:
>
> compile error:
>
> procedure declaration does not match description of event or procedure
> having the same name
>
> code in commmandbutton1:
> Private Sub CommandButton1_Click(ByVal target As Range)
>
> Dim Temp As Variant
>
> If Target.Column = 1 Then
> Application.EnableEvents = False
> Temp = Split(Target.Value, "^")
>
> Target.Value = Mid(Temp(0), 2)
> Target.Offset(0, 1).Value = Temp(1)
> Target.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
>
> Application.EnableEvents = True
> End If
> End Sub
>
>
> thanks
>



 
Reply With Quote
 
=?Utf-8?B?c2ltb24=?=
Guest
Posts: n/a
 
      16th Nov 2006
You mean this?
Private Sub CommandButton1_Click()
Dim Temp As Variant

If activecell.Column = 1 Then
Application.EnableEvents = False
Temp = Split(activecell.Value, "^")

activecell.Value = Mid(Temp(0), 2)
activecell.Offset(0, 1).Value = Temp(1)
activecell.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
Application.EnableEvents = True
End If

End Sub


"NickHK" wrote:

> Simon,
> You cannot create any event declaration you like; it has to be what the
> object is expecting.
> It is easier to get VBA to generate the stub for you, so add a command
> button, then double click it. Excel/VBA will generate the required _Click
> outline for you.
>
> You will see that you do not have any arguments, only empty brackets.
> Therefore, you need to ActiveCell in you code instead of Target.
>
> NickHK
>
> "simon" <(E-Mail Removed)> wrote in message
> news:831B0953-D2F3-441E-98EE-(E-Mail Removed)...
> > Hi,
> > every time compile code get error:
> >
> > compile error:
> >
> > procedure declaration does not match description of event or procedure
> > having the same name
> >
> > code in commmandbutton1:
> > Private Sub CommandButton1_Click(ByVal target As Range)
> >
> > Dim Temp As Variant
> >
> > If Target.Column = 1 Then
> > Application.EnableEvents = False
> > Temp = Split(Target.Value, "^")
> >
> > Target.Value = Mid(Temp(0), 2)
> > Target.Offset(0, 1).Value = Temp(1)
> > Target.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
> >
> > Application.EnableEvents = True
> > End If
> > End Sub
> >
> >
> > thanks
> >

>
>
>

 
Reply With Quote
 
=?Utf-8?B?c2ltb24=?=
Guest
Posts: n/a
 
      16th Nov 2006
code not work


"simon" wrote:

> You mean this?
> Private Sub CommandButton1_Click()
> Dim Temp As Variant
>
> If activecell.Column = 1 Then
> Application.EnableEvents = False
> Temp = Split(activecell.Value, "^")
>
> activecell.Value = Mid(Temp(0), 2)
> activecell.Offset(0, 1).Value = Temp(1)
> activecell.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
> Application.EnableEvents = True
> End If
>
> End Sub
>
>
> "NickHK" wrote:
>
> > Simon,
> > You cannot create any event declaration you like; it has to be what the
> > object is expecting.
> > It is easier to get VBA to generate the stub for you, so add a command
> > button, then double click it. Excel/VBA will generate the required _Click
> > outline for you.
> >
> > You will see that you do not have any arguments, only empty brackets.
> > Therefore, you need to ActiveCell in you code instead of Target.
> >
> > NickHK
> >
> > "simon" <(E-Mail Removed)> wrote in message
> > news:831B0953-D2F3-441E-98EE-(E-Mail Removed)...
> > > Hi,
> > > every time compile code get error:
> > >
> > > compile error:
> > >
> > > procedure declaration does not match description of event or procedure
> > > having the same name
> > >
> > > code in commmandbutton1:
> > > Private Sub CommandButton1_Click(ByVal target As Range)
> > >
> > > Dim Temp As Variant
> > >
> > > If Target.Column = 1 Then
> > > Application.EnableEvents = False
> > > Temp = Split(Target.Value, "^")
> > >
> > > Target.Value = Mid(Temp(0), 2)
> > > Target.Offset(0, 1).Value = Temp(1)
> > > Target.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
> > >
> > > Application.EnableEvents = True
> > > End If
> > > End Sub
> > >
> > >
> > > thanks
> > >

> >
> >
> >

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      16th Nov 2006
Well, an error number/description or some help from you would help.

NickHK

"simon" <(E-Mail Removed)> wrote in message
news:A448576F-1C0D-4D7E-A1B6-(E-Mail Removed)...
> code not work
>
>
> "simon" wrote:
>
> > You mean this?
> > Private Sub CommandButton1_Click()
> > Dim Temp As Variant
> >
> > If activecell.Column = 1 Then
> > Application.EnableEvents = False
> > Temp = Split(activecell.Value, "^")
> >
> > activecell.Value = Mid(Temp(0), 2)
> > activecell.Offset(0, 1).Value = Temp(1)
> > activecell.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
> > Application.EnableEvents = True
> > End If
> >
> > End Sub
> >
> >
> > "NickHK" wrote:
> >
> > > Simon,
> > > You cannot create any event declaration you like; it has to be what

the
> > > object is expecting.
> > > It is easier to get VBA to generate the stub for you, so add a command
> > > button, then double click it. Excel/VBA will generate the required

_Click
> > > outline for you.
> > >
> > > You will see that you do not have any arguments, only empty brackets.
> > > Therefore, you need to ActiveCell in you code instead of Target.
> > >
> > > NickHK
> > >
> > > "simon" <(E-Mail Removed)> wrote in message
> > > news:831B0953-D2F3-441E-98EE-(E-Mail Removed)...
> > > > Hi,
> > > > every time compile code get error:
> > > >
> > > > compile error:
> > > >
> > > > procedure declaration does not match description of event or

procedure
> > > > having the same name
> > > >
> > > > code in commmandbutton1:
> > > > Private Sub CommandButton1_Click(ByVal target As Range)
> > > >
> > > > Dim Temp As Variant
> > > >
> > > > If Target.Column = 1 Then
> > > > Application.EnableEvents = False
> > > > Temp = Split(Target.Value, "^")
> > > >
> > > > Target.Value = Mid(Temp(0), 2)
> > > > Target.Offset(0, 1).Value = Temp(1)
> > > > Target.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
> > > >
> > > > Application.EnableEvents = True
> > > > End If
> > > > End Sub
> > > >
> > > >
> > > > thanks
> > > >
> > >
> > >
> > >



 
Reply With Quote
 
=?Utf-8?B?c2ltb24=?=
Guest
Posts: n/a
 
      17th Nov 2006
run-time error '9':
Subscript out of range

"NickHK" wrote:

> Well, an error number/description or some help from you would help.
>
> NickHK
>
> "simon" <(E-Mail Removed)> wrote in message
> news:A448576F-1C0D-4D7E-A1B6-(E-Mail Removed)...
> > code not work
> >
> >
> > "simon" wrote:
> >
> > > You mean this?
> > > Private Sub CommandButton1_Click()
> > > Dim Temp As Variant
> > >
> > > If activecell.Column = 1 Then
> > > Application.EnableEvents = False
> > > Temp = Split(activecell.Value, "^")
> > >
> > > activecell.Value = Mid(Temp(0), 2)
> > > activecell.Offset(0, 1).Value = Temp(1)
> > > activecell.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
> > > Application.EnableEvents = True
> > > End If
> > >
> > > End Sub
> > >
> > >
> > > "NickHK" wrote:
> > >
> > > > Simon,
> > > > You cannot create any event declaration you like; it has to be what

> the
> > > > object is expecting.
> > > > It is easier to get VBA to generate the stub for you, so add a command
> > > > button, then double click it. Excel/VBA will generate the required

> _Click
> > > > outline for you.
> > > >
> > > > You will see that you do not have any arguments, only empty brackets.
> > > > Therefore, you need to ActiveCell in you code instead of Target.
> > > >
> > > > NickHK
> > > >
> > > > "simon" <(E-Mail Removed)> wrote in message
> > > > news:831B0953-D2F3-441E-98EE-(E-Mail Removed)...
> > > > > Hi,
> > > > > every time compile code get error:
> > > > >
> > > > > compile error:
> > > > >
> > > > > procedure declaration does not match description of event or

> procedure
> > > > > having the same name
> > > > >
> > > > > code in commmandbutton1:
> > > > > Private Sub CommandButton1_Click(ByVal target As Range)
> > > > >
> > > > > Dim Temp As Variant
> > > > >
> > > > > If Target.Column = 1 Then
> > > > > Application.EnableEvents = False
> > > > > Temp = Split(Target.Value, "^")
> > > > >
> > > > > Target.Value = Mid(Temp(0), 2)
> > > > > Target.Offset(0, 1).Value = Temp(1)
> > > > > Target.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
> > > > >
> > > > > Application.EnableEvents = True
> > > > > End If
> > > > > End Sub
> > > > >
> > > > >
> > > > > thanks
> > > > >
> > > >
> > > >
> > > >

>
>
>

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      17th Nov 2006
That means you are trying to access an element in collection or array that
does not exist.
So it seems that "activecell.Value" does not contain what you think, i.e.. 3
"^" characters. You should check you have the correct values, maybe
If UBound(Temp)=2 Then 'OK

But you are not using the code posted below, because "activecell.Value"
would be "Activecell.Value".

NickHK

"simon" <(E-Mail Removed)> wrote in message
news:588F3F05-5644-4EA8-9D8B-(E-Mail Removed)...
> run-time error '9':
> Subscript out of range
>
> "NickHK" wrote:
>
> > Well, an error number/description or some help from you would help.
> >
> > NickHK
> >
> > "simon" <(E-Mail Removed)> wrote in message
> > news:A448576F-1C0D-4D7E-A1B6-(E-Mail Removed)...
> > > code not work
> > >
> > >
> > > "simon" wrote:
> > >
> > > > You mean this?
> > > > Private Sub CommandButton1_Click()
> > > > Dim Temp As Variant
> > > >
> > > > If activecell.Column = 1 Then
> > > > Application.EnableEvents = False
> > > > Temp = Split(activecell.Value, "^")
> > > >
> > > > activecell.Value = Mid(Temp(0), 2)
> > > > activecell.Offset(0, 1).Value = Temp(1)
> > > > activecell.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
> > > > Application.EnableEvents = True
> > > > End If
> > > >
> > > > End Sub
> > > >
> > > >
> > > > "NickHK" wrote:
> > > >
> > > > > Simon,
> > > > > You cannot create any event declaration you like; it has to be

what
> > the
> > > > > object is expecting.
> > > > > It is easier to get VBA to generate the stub for you, so add a

command
> > > > > button, then double click it. Excel/VBA will generate the required

> > _Click
> > > > > outline for you.
> > > > >
> > > > > You will see that you do not have any arguments, only empty

brackets.
> > > > > Therefore, you need to ActiveCell in you code instead of Target.
> > > > >
> > > > > NickHK
> > > > >
> > > > > "simon" <(E-Mail Removed)> wrote in message
> > > > > news:831B0953-D2F3-441E-98EE-(E-Mail Removed)...
> > > > > > Hi,
> > > > > > every time compile code get error:
> > > > > >
> > > > > > compile error:
> > > > > >
> > > > > > procedure declaration does not match description of event or

> > procedure
> > > > > > having the same name
> > > > > >
> > > > > > code in commmandbutton1:
> > > > > > Private Sub CommandButton1_Click(ByVal target As Range)
> > > > > >
> > > > > > Dim Temp As Variant
> > > > > >
> > > > > > If Target.Column = 1 Then
> > > > > > Application.EnableEvents = False
> > > > > > Temp = Split(Target.Value, "^")
> > > > > >
> > > > > > Target.Value = Mid(Temp(0), 2)
> > > > > > Target.Offset(0, 1).Value = Temp(1)
> > > > > > Target.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
> > > > > >
> > > > > > Application.EnableEvents = True
> > > > > > End If
> > > > > > End Sub
> > > > > >
> > > > > >
> > > > > > thanks
> > > > > >
> > > > >
> > > > >
> > > > >

> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?c2ltb24=?=
Guest
Posts: n/a
 
      21st Nov 2006
In fact, these code work well

Private Sub Worksheet_Activate()
Dim Temp As Variant
If Target.Column = 1 Then
Application.EnableEvents = False
Temp = Split(Target.Value, "^")
Target.Value = Mid(Temp(0), 2)
Target.Offset(0, 1).Value = Temp(1)
Target.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
Application.EnableEvents = True
End If
End Sub

The problem is that I can't put above code in button to work
or a form to read it into the cell i want.

"NickHK" wrote:

> That means you are trying to access an element in collection or array that
> does not exist.
> So it seems that "activecell.Value" does not contain what you think, i.e.. 3
> "^" characters. You should check you have the correct values, maybe
> If UBound(Temp)=2 Then 'OK
>
> But you are not using the code posted below, because "activecell.Value"
> would be "Activecell.Value".
>
> NickHK
>
> "simon" <(E-Mail Removed)> wrote in message
> news:588F3F05-5644-4EA8-9D8B-(E-Mail Removed)...
> > run-time error '9':
> > Subscript out of range
> >
> > "NickHK" wrote:
> >
> > > Well, an error number/description or some help from you would help.
> > >
> > > NickHK
> > >
> > > "simon" <(E-Mail Removed)> wrote in message
> > > news:A448576F-1C0D-4D7E-A1B6-(E-Mail Removed)...
> > > > code not work
> > > >
> > > >
> > > > "simon" wrote:
> > > >
> > > > > You mean this?
> > > > > Private Sub CommandButton1_Click()
> > > > > Dim Temp As Variant
> > > > >
> > > > > If activecell.Column = 1 Then
> > > > > Application.EnableEvents = False
> > > > > Temp = Split(activecell.Value, "^")
> > > > >
> > > > > activecell.Value = Mid(Temp(0), 2)
> > > > > activecell.Offset(0, 1).Value = Temp(1)
> > > > > activecell.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
> > > > > Application.EnableEvents = True
> > > > > End If
> > > > >
> > > > > End Sub
> > > > >
> > > > >
> > > > > "NickHK" wrote:
> > > > >
> > > > > > Simon,
> > > > > > You cannot create any event declaration you like; it has to be

> what
> > > the
> > > > > > object is expecting.
> > > > > > It is easier to get VBA to generate the stub for you, so add a

> command
> > > > > > button, then double click it. Excel/VBA will generate the required
> > > _Click
> > > > > > outline for you.
> > > > > >
> > > > > > You will see that you do not have any arguments, only empty

> brackets.
> > > > > > Therefore, you need to ActiveCell in you code instead of Target.
> > > > > >
> > > > > > NickHK
> > > > > >
> > > > > > "simon" <(E-Mail Removed)> wrote in message
> > > > > > news:831B0953-D2F3-441E-98EE-(E-Mail Removed)...
> > > > > > > Hi,
> > > > > > > every time compile code get error:
> > > > > > >
> > > > > > > compile error:
> > > > > > >
> > > > > > > procedure declaration does not match description of event or
> > > procedure
> > > > > > > having the same name
> > > > > > >
> > > > > > > code in commmandbutton1:
> > > > > > > Private Sub CommandButton1_Click(ByVal target As Range)
> > > > > > >
> > > > > > > Dim Temp As Variant
> > > > > > >
> > > > > > > If Target.Column = 1 Then
> > > > > > > Application.EnableEvents = False
> > > > > > > Temp = Split(Target.Value, "^")
> > > > > > >
> > > > > > > Target.Value = Mid(Temp(0), 2)
> > > > > > > Target.Offset(0, 1).Value = Temp(1)
> > > > > > > Target.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
> > > > > > >
> > > > > > > Application.EnableEvents = True
> > > > > > > End If
> > > > > > > End Sub
> > > > > > >
> > > > > > >
> > > > > > > thanks
> > > > > > >
> > > > > >
> > > > > >
> > > > > >
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      21st Nov 2006
Simon,
What is Target ?
Normally it does not exist an event like Worksheet_Activate.

Use ActiveCell instead, or specify the range e.g. Range("A1") etc

NickHK

"simon" <(E-Mail Removed)> wrote in message
news:12FDBE9B-B9FE-484B-A61B-(E-Mail Removed)...
> In fact, these code work well
>
> Private Sub Worksheet_Activate()
> Dim Temp As Variant
> If Target.Column = 1 Then
> Application.EnableEvents = False
> Temp = Split(Target.Value, "^")
> Target.Value = Mid(Temp(0), 2)
> Target.Offset(0, 1).Value = Temp(1)
> Target.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
> Application.EnableEvents = True
> End If
> End Sub
>
> The problem is that I can't put above code in button to work
> or a form to read it into the cell i want.
>
> "NickHK" wrote:
>
> > That means you are trying to access an element in collection or array

that
> > does not exist.
> > So it seems that "activecell.Value" does not contain what you think,

i.e.. 3
> > "^" characters. You should check you have the correct values, maybe
> > If UBound(Temp)=2 Then 'OK
> >
> > But you are not using the code posted below, because "activecell.Value"
> > would be "Activecell.Value".
> >
> > NickHK
> >
> > "simon" <(E-Mail Removed)> wrote in message
> > news:588F3F05-5644-4EA8-9D8B-(E-Mail Removed)...
> > > run-time error '9':
> > > Subscript out of range
> > >
> > > "NickHK" wrote:
> > >
> > > > Well, an error number/description or some help from you would help.
> > > >
> > > > NickHK
> > > >
> > > > "simon" <(E-Mail Removed)> wrote in message
> > > > news:A448576F-1C0D-4D7E-A1B6-(E-Mail Removed)...
> > > > > code not work
> > > > >
> > > > >
> > > > > "simon" wrote:
> > > > >
> > > > > > You mean this?
> > > > > > Private Sub CommandButton1_Click()
> > > > > > Dim Temp As Variant
> > > > > >
> > > > > > If activecell.Column = 1 Then
> > > > > > Application.EnableEvents = False
> > > > > > Temp = Split(activecell.Value, "^")
> > > > > >
> > > > > > activecell.Value = Mid(Temp(0), 2)
> > > > > > activecell.Offset(0, 1).Value = Temp(1)
> > > > > > activecell.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
> > > > > > Application.EnableEvents = True
> > > > > > End If
> > > > > >
> > > > > > End Sub
> > > > > >
> > > > > >
> > > > > > "NickHK" wrote:
> > > > > >
> > > > > > > Simon,
> > > > > > > You cannot create any event declaration you like; it has to be

> > what
> > > > the
> > > > > > > object is expecting.
> > > > > > > It is easier to get VBA to generate the stub for you, so add a

> > command
> > > > > > > button, then double click it. Excel/VBA will generate the

required
> > > > _Click
> > > > > > > outline for you.
> > > > > > >
> > > > > > > You will see that you do not have any arguments, only empty

> > brackets.
> > > > > > > Therefore, you need to ActiveCell in you code instead of

Target.
> > > > > > >
> > > > > > > NickHK
> > > > > > >
> > > > > > > "simon" <(E-Mail Removed)> wrote in message
> > > > > > > news:831B0953-D2F3-441E-98EE-(E-Mail Removed)...
> > > > > > > > Hi,
> > > > > > > > every time compile code get error:
> > > > > > > >
> > > > > > > > compile error:
> > > > > > > >
> > > > > > > > procedure declaration does not match description of event or
> > > > procedure
> > > > > > > > having the same name
> > > > > > > >
> > > > > > > > code in commmandbutton1:
> > > > > > > > Private Sub CommandButton1_Click(ByVal target As Range)
> > > > > > > >
> > > > > > > > Dim Temp As Variant
> > > > > > > >
> > > > > > > > If Target.Column = 1 Then
> > > > > > > > Application.EnableEvents = False
> > > > > > > > Temp = Split(Target.Value, "^")
> > > > > > > >
> > > > > > > > Target.Value = Mid(Temp(0), 2)
> > > > > > > > Target.Offset(0, 1).Value = Temp(1)
> > > > > > > > Target.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
> > > > > > > >
> > > > > > > > Application.EnableEvents = True
> > > > > > > > End If
> > > > > > > > End Sub
> > > > > > > >
> > > > > > > >
> > > > > > > > thanks
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > >
> > > >
> > > >
> > > >

> >
> >
> >



 
Reply With Quote
 
=?Utf-8?B?c2ltb24=?=
Guest
Posts: n/a
 
      24th Nov 2006
NickHK,
Sorry it should be worksheet_change as following code, but I want to try
merge these code in a command button, to turn on or off this read and splite
the read function.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Temp As Variant
If Target.Column = 1 Then
Application.EnableEvents = False
Temp = Split(Target.Value, "^")
Target.Value = Mid(Temp(0), 2)
Target.Offset(0, 1).Value = Temp(1)
Target.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
Application.EnableEvents = True
End If
End Sub

"NickHK" wrote:

> Simon,
> What is Target ?
> Normally it does not exist an event like Worksheet_Activate.
>
> Use ActiveCell instead, or specify the range e.g. Range("A1") etc
>
> NickHK
>
> "simon" <(E-Mail Removed)> wrote in message
> news:12FDBE9B-B9FE-484B-A61B-(E-Mail Removed)...
> > In fact, these code work well
> >
> > Private Sub Worksheet_Activate()
> > Dim Temp As Variant
> > If Target.Column = 1 Then
> > Application.EnableEvents = False
> > Temp = Split(Target.Value, "^")
> > Target.Value = Mid(Temp(0), 2)
> > Target.Offset(0, 1).Value = Temp(1)
> > Target.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
> > Application.EnableEvents = True
> > End If
> > End Sub
> >
> > The problem is that I can't put above code in button to work
> > or a form to read it into the cell i want.
> >
> > "NickHK" wrote:
> >
> > > That means you are trying to access an element in collection or array

> that
> > > does not exist.
> > > So it seems that "activecell.Value" does not contain what you think,

> i.e.. 3
> > > "^" characters. You should check you have the correct values, maybe
> > > If UBound(Temp)=2 Then 'OK
> > >
> > > But you are not using the code posted below, because "activecell.Value"
> > > would be "Activecell.Value".
> > >
> > > NickHK
> > >
> > > "simon" <(E-Mail Removed)> wrote in message
> > > news:588F3F05-5644-4EA8-9D8B-(E-Mail Removed)...
> > > > run-time error '9':
> > > > Subscript out of range
> > > >
> > > > "NickHK" wrote:
> > > >
> > > > > Well, an error number/description or some help from you would help.
> > > > >
> > > > > NickHK
> > > > >
> > > > > "simon" <(E-Mail Removed)> wrote in message
> > > > > news:A448576F-1C0D-4D7E-A1B6-(E-Mail Removed)...
> > > > > > code not work
> > > > > >
> > > > > >
> > > > > > "simon" wrote:
> > > > > >
> > > > > > > You mean this?
> > > > > > > Private Sub CommandButton1_Click()
> > > > > > > Dim Temp As Variant
> > > > > > >
> > > > > > > If activecell.Column = 1 Then
> > > > > > > Application.EnableEvents = False
> > > > > > > Temp = Split(activecell.Value, "^")
> > > > > > >
> > > > > > > activecell.Value = Mid(Temp(0), 2)
> > > > > > > activecell.Offset(0, 1).Value = Temp(1)
> > > > > > > activecell.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
> > > > > > > Application.EnableEvents = True
> > > > > > > End If
> > > > > > >
> > > > > > > End Sub
> > > > > > >
> > > > > > >
> > > > > > > "NickHK" wrote:
> > > > > > >
> > > > > > > > Simon,
> > > > > > > > You cannot create any event declaration you like; it has to be
> > > what
> > > > > the
> > > > > > > > object is expecting.
> > > > > > > > It is easier to get VBA to generate the stub for you, so add a
> > > command
> > > > > > > > button, then double click it. Excel/VBA will generate the

> required
> > > > > _Click
> > > > > > > > outline for you.
> > > > > > > >
> > > > > > > > You will see that you do not have any arguments, only empty
> > > brackets.
> > > > > > > > Therefore, you need to ActiveCell in you code instead of

> Target.
> > > > > > > >
> > > > > > > > NickHK
> > > > > > > >
> > > > > > > > "simon" <(E-Mail Removed)> wrote in message
> > > > > > > > news:831B0953-D2F3-441E-98EE-(E-Mail Removed)...
> > > > > > > > > Hi,
> > > > > > > > > every time compile code get error:
> > > > > > > > >
> > > > > > > > > compile error:
> > > > > > > > >
> > > > > > > > > procedure declaration does not match description of event or
> > > > > procedure
> > > > > > > > > having the same name
> > > > > > > > >
> > > > > > > > > code in commmandbutton1:
> > > > > > > > > Private Sub CommandButton1_Click(ByVal target As Range)
> > > > > > > > >
> > > > > > > > > Dim Temp As Variant
> > > > > > > > >
> > > > > > > > > If Target.Column = 1 Then
> > > > > > > > > Application.EnableEvents = False
> > > > > > > > > Temp = Split(Target.Value, "^")
> > > > > > > > >
> > > > > > > > > Target.Value = Mid(Temp(0), 2)
> > > > > > > > > Target.Offset(0, 1).Value = Temp(1)
> > > > > > > > > Target.Offset(0, 2).Value = Left(Temp(2), Len(Temp(2)) - 1)
> > > > > > > > >
> > > > > > > > > Application.EnableEvents = True
> > > > > > > > > End If
> > > > > > > > > End Sub
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > thanks
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > >
> > > > >
> > > > >
> > >
> > >
> > >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
RE: moved vba code from macro to command button, now won't work =?Utf-8?B?Q2hhcmxlcyBDaGlja2VyaW5n?= Microsoft Excel Programming 0 12th Jan 2007 10:18 PM
Command Button Work once a day =?Utf-8?B?Q3Jhenlob3JzZQ==?= Microsoft Access Forms 2 17th Feb 2006 04:55 PM
RE: Add Command Button Does not work =?Utf-8?B?S2xhdHV1?= Microsoft Access Forms 0 18th May 2005 05:42 PM
macro code doesnt work in command button The Grinch Microsoft Excel Programming 4 22nd Jul 2004 06:28 PM
Executing C code from a Command Button's code =?Utf-8?B?bmpj?= Microsoft Word Document Management 1 19th Apr 2004 10:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:17 PM.