Error Message When Run Under Cmd_click

  • i can run this code as a macro, but i get an error "1004" when i run under a command button...?


    Code
    Range("A2:H36").Select
        Selection.Copy
        Sheets("Letterhead").Select
        Range("A8").Select
        Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:= _
            xlNone, SkipBlanks:=False, Transpose:=False


    ???


    thanks...

  • Re: Error Message When Run Under Cmd_click



    Don't Activate/Select

    Code
    Sheets("SheetNameHere").Range("a2:h36").Copy
    Sheets("Letterhead").Range("a8").PasteSpecial xlPasteValuesAndNumberFormats
  • Re: Error Message When Run Under Cmd_click


    The reason your original code was causing an error is when you add a command button to a sheet the button takefocusonClick default property is set to true.
    I recommned you also change the property to false.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!