+ Reply to Thread
Results 1 to 14 of 14

Select method class range failed

  1. #1
    Registered User
    Join Date
    05-04-2007
    Posts
    42

    Select method class range failed

    Hi,
    I have created a spreadsheet that is 38mb and needed to size it down. I recorded the following macro to do this. This essentialy jut copies the top line of the relevant columns on each page and then copies the formulas down, calculates, and then pastes just the values of these calculations, thereby reducing the sheet to a third of its size. The macro works if I run it from the macro option on the toolbar, but when I assign it to a command button I keep getting ' select method class range failed'.
    Can anyone help???

    Please Login or Register  to view this content.
    Last edited by VBA Noob; 10-31-2007 at 03:57 AM.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480
    I could not replicate the problem

    here's a shorter version of the macro, that has gotten rid of all the selects
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor VBA Noob's Avatar
    Join Date
    04-25-2006
    Location
    London, England
    MS-Off Ver
    xl03 & xl 07(Jan 09)
    Posts
    11,988
    Dave,

    Would you not use somthing like

    Please Login or Register  to view this content.
    or he wants only wants to paste special formulas in a range

    Please Login or Register  to view this content.
    Also this link may help reduce the size of your file

    http://www.contextures.com/xlfaqApp.html#Unused

    http://www.decisionmodels.com/optspeedb.htm

    VBA Noob
    _________________________________________


    Credo Elvem ipsum etian vivere
    _________________________________________
    A message for cross posters

    Please remember to wrap code.

    Forum Rules

    Please add to your signature if you found this link helpful. Excel links !!!

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480
    Quote Originally Posted by VBA Noob
    Dave,

    Would you not use somthing like

    Please Login or Register  to view this content.
    or he wants only wants to paste special formulas in a range

    Please Login or Register  to view this content.
    Also this link may help reduce the size of your file

    http://www.contextures.com/xlfaqApp.html#Unused

    http://www.decisionmodels.com/optspeedb.htm

    VBA Noob
    Certainly that would work....
    The poster is in the beginning stage of learning VBA and thought
    copy- destination would be a good code to understand the first time

  5. #5
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480
    Hi phillb,
    Try and attach a sample of the workbook, so we can see if there is a pattern, maybe you are trying to find the first empty row or something in that area,
    Quite unsure as to what you are tying to accomplish

  6. #6
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    If the Command Button is from the Contol Toolbox toolbar it could be because the property setting for the TakeFocusOnClick is set to True (This is the the default setting).
    This can cause a problem when you try & paste even when you use commands to select cells before pasting


    To change this setting

    Open Control Toolbox Toolbar

    Click on the Triangle shaped Icon (This will put you in Edit mode)
    Right Click on the button
    Select Properties
    Change TakeFocusOnClick setting to False
    Click on the Triangle shaped Icon (This will take you out of Edit mode)
    Last edited by mudraker; 10-31-2007 at 07:51 AM.
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  7. #7
    Registered User
    Join Date
    05-04-2007
    Posts
    42
    I can't send an example. even with nearly everything taken out and zipped it is still too large.

    The changing of the button in design view didn't work, and I am still getting the error when it moves onto sheet maintenance select line

  8. #8
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Can you post the book on a file sharing website like rapidshare.com & then provide a link to it?

  9. #9
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480
    Quote Originally Posted by phillb
    I can't send an example. even with nearly everything taken out and zipped it is still too large.

    The changing of the button in design view didn't work, and I am still getting the error when it moves onto sheet maintenance select line
    did you not try the code I sent you?
    you should have no selects!!!

  10. #10
    Registered User
    Join Date
    05-04-2007
    Posts
    42
    I have just tried it. it seems to do some quite weird things. It seems to delete on the first sheet the formulae in cell c4 and d4. It then seems to copy cells M3:R3 and also T3:W3. I can't see any reason for this as all of the formulae in the macro you wrote point to row 4.

  11. #11
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,480
    Quote Originally Posted by phillb
    I have just tried it. it seems to do some quite weird things. It seems to delete on the first sheet the formulae in cell c4 and d4. It then seems to copy cells M3:R3 and also T3:W3. I can't see any reason for this as all of the formulae in the macro you wrote point to row 4.
    That is strange, considering it's your macro, just without the selects, but if you look at it you should be able to figure out how to adjust the code

  12. #12
    Registered User
    Join Date
    05-04-2007
    Posts
    42
    It is bizzare. I have tried just running the macro in part to see if I can identify the problem as the references look okay to me and it runs fine when divided into sections, But as a whole it still brings up that problem of copying and pasting incorrectly

  13. #13
    Registered User
    Join Date
    05-04-2007
    Posts
    42
    I have tried to compress an example copy, but I can only reduce it too 500KB. Is there any other way of posting or sending an example of this??

  14. #14
    Registered User
    Join Date
    05-04-2007
    Posts
    42
    I have worked out what the porblem is but am unsure of how to fix it. It seems that the second set of copies and pastes is occuring within the first sheet selected and ht macro is not selecting the right sheet. I have attempted to use selects to define which sheets it needs to select, but it is still not recognising this.

+ 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