View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default code for command button not work

Well, an error number/description or some help from you would help.

NickHK

"simon" wrote in message
...
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" wrote in message
...
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