+ Reply to Thread
Results 1 to 3 of 3

Selecting all cells in a worksheet using commandbutton

  1. #1
    Registered User
    Join Date
    06-01-2011
    Location
    norway
    MS-Off Ver
    Excel 2003
    Posts
    15

    Selecting all cells in a worksheet using commandbutton

    Something strange (at least for me).
    When I record a macro that selects all the cells in a workbook and clear all content the code looks like this:
    Please Login or Register  to view this content.
    This works fine. However when I have the same code inside a commandobutton it fails and gives me the error code "application-defined or object defined error". Anyone that knows why and how this can be done correct? I want this to be done within the commandbutton code.

    The code that fails looks like:
    Please Login or Register  to view this content.

  2. #2
    Forum Contributor vikas.bhandari's Avatar
    Join Date
    04-07-2006
    Location
    Delhi, India
    MS-Off Ver
    Office 2007 and 2010
    Posts
    303

    Re: Selecting all cells in a worksheet using commandbutton

    I would do this :

    Please Login or Register  to view this content.

    This would work anytime, anywhere in your workbook.

    Thanks,
    Vikas

  3. #3
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,341

    Re: Selecting all cells in a worksheet using commandbutton

    As you aren't reusing the variable, you can just use:
    Please Login or Register  to view this content.
    or even:
    Please Login or Register  to view this content.
    Everyone who confuses correlation and causation ends up dead.

+ 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