+ Reply to Thread
Results 1 to 6 of 6

Having difficulty with VB on a button "Run-time error 1004"

  1. #1
    Registered User
    Join Date
    03-27-2013
    Location
    Boston, MA
    MS-Off Ver
    Excel 2010
    Posts
    50

    Having difficulty with VB on a button "Run-time error 1004"

    Hi,

    I'm having difficulty and am receiving an error when I launch a macros that I've embedded into a button on VBA. I created a control button and attached the macro. When I use the control button I get run time error 1004 with the message that says "Select method of range class failed."

    Here's the code: (the error occurs on the {"Range ("A2").Select} line_




    Private Sub CommandButton2_Click()
    '
    'Button226_Click Macro
    '
    'Keyboard Shortcut: Ctrl Shift + J
    '

    Range("C2").Select
    Selection.Copy
    Sheets("Recommendations").Select
    Range("A2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Sheets("Decision Matrix").Select
    ActiveWindow.SmallScroll Down:=27
    Range("G55").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Recommendations").Select
    Range("B2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    Sheets("Decision Matrix").Select
    Range("H55").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Recommendations").Select
    Range("E2").Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
    End Sub


    Can anyone help?

    Thank you!

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Having difficulty with VB on a button "Run-time error 1004"

    Don't quote the range property within double quotes "Range

    I just fine tuned your code little bit

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Registered User
    Join Date
    03-27-2013
    Location
    Boston, MA
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Having difficulty with VB on a button "Run-time error 1004"

    Thanks man, quick follow-up.

    If insted of copying it onto A2, B2, and E2 --- say I wanted it to automoatically record the copied materials and move to the cell bellow (A3, B3, and E3), and then copy again once the button is clicked, and then once again move to A4, B4, E4

    Can this be done?

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,770

    Re: Having difficulty with VB on a button "Run-time error 1004"

    This is seems to be a another new question so you can start a new thread

  5. #5
    Registered User
    Join Date
    03-27-2013
    Location
    Boston, MA
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Having difficulty with VB on a button "Run-time error 1004"

    I shall, thank you.

    Please check the new questions here, and thanks for the help:

    http://www.excelforum.com/excel-prog...16#post3303216

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Having difficulty with VB on a button "Run-time error 1004"

    Hi, andyaf,

    Your opening post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    FYI: there was an answer posted in your new thread before you added your last post here.

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1