+ Reply to Thread
Results 1 to 11 of 11

Run-time error when running macro from personal workbook

  1. #1
    Registered User
    Join Date
    05-20-2008
    Posts
    9

    Run-time error when running macro from personal workbook

    Hi,

    I have a very simple macro that i use to divide a an entire column (besides the header row) by 1000...

    Please Login or Register  to view this content.
    It works fine as long as the macro is attached to the workbook in which I am trying to use it. If the macro is attached to the personal workbook, I get a runtime error when I attempt to run it...

    Run-time error '1004':

    Method 'Range' of object '_Worksheet' failed


    When I hit Debug, this line is highlighted...

    Please Login or Register  to view this content.
    There appears to be some confusion when the range is defined, but I don't see why which workbook the macro is attached to should make a difference.

    I am VERY new to this, so any help would be appreciated.

    Thanks,
    Corey

  2. #2
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,163
    I get the error no matter where the macro is.
    Try this.
    Please Login or Register  to view this content.
    Regards

    Rick
    Win10, Office 365

  3. #3
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Here's another way:
    Please Login or Register  to view this content.

  4. #4
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,163
    Damn you and your clean compact code!


  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    .

  6. #6
    Registered User
    Join Date
    05-20-2008
    Posts
    9
    Thanks very much for the replies guys. Rick's code worked like a charm. When I tried shg's code, I got the following error:

    Run-time error '1004':

    No cells were found


    Upon debugging, the following line of code was highlighted...

    Set rBlank = ActiveSheet.Cells.SpecialCells(xlCellTypeBlanks).Cells(1, 1)

    Like I said, I'm a complete noob, so it's entirely possible that I deployed it wrong. I've just been cutting and pasting these into Visual Basic. Any thoughts?

    Thanks again for your replies and patience.

    -Corey

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    This works for me

    Please Login or Register  to view this content.
    You need an On Error statement to avoid the error if no special cells are found.
    Last edited by royUK; 05-21-2008 at 09:41 AM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678
    Rick's code worked like a charm. When I tried shg's code, I got the following error
    Go, Rick

    Don't see why mine should error unless the sheet is full, but haven't looked closely.

  9. #9
    Registered User
    Join Date
    05-20-2008
    Posts
    9
    You guys are awesome.

    Stay tuned for more new guy type problems

  10. #10
    Forum Contributor Rick_Stanich's Avatar
    Join Date
    11-21-2005
    Location
    Ladson SC
    MS-Off Ver
    Office365
    Posts
    1,163
    This should help control errors.
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    05-20-2008
    Posts
    9

    Talking

    Thanks Rick!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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