• Error while running paste special macro (excel 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Error while running paste special macro (excel 2000)

    • This topic has 3 replies, 2 voices, and was last updated 21 years ago.
    Author
    Topic
    #404293

    Hi again guys….

    Sub Name()

    ‘name
    Sheets(“GlobalKelas”).Select
    Range(“b7:b48”).Select
    Selection.Copy

    Sheets(“All”).Select
    ActiveSheet.Unprotect Password:=””
    Range(“b7″).Select
    Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False

    End Sub

    Above code always keeps getting error :

    ” Run Time Error 1004

    PasteSpecial method of Range class failed ”

    and highlight this :

    ” Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
    False, Transpose:=False ”

    Why this thing occured and how can I overcome it..thanks a zillion

    Viewing 0 reply threads
    Author
    Replies
    • #821332

      “Name” is not a good name for a macro, since it is a property of many things in VBA. The code can be shortened to this, avoiding selecting worksheets and cells:

      Sub Test()
      Sheets(“GlobalKelas”).Range(“B7:B48”).Copy
      With Sheets(“All”)
      .Unprotect Password:=””
      .Range(“B7”).PasteSpecial Paste:=xlValues
      End With
      End Sub

      I see no reason why it shouldn’t work – I don’t get an error when I run either your version or mine in a test workbook with worksheets GlobalKelas and All.

    Viewing 0 reply threads
    Reply To: Error while running paste special macro (excel 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: