+ Reply to Thread
Results 1 to 12 of 12

type mismatch on cell contents. Cell.clearcontents

  1. #1
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    type mismatch on cell contents. Cell.clearcontents

    Hi there,

    I have a simple formula procedure which is linked to a button. When the button is clicked, nothing happens even though ranges have values.

    Please Login or Register  to view this content.
    Columns have values, but this button doesn't really clear them.

    Is anyone able to assist?

    Thanks
    Last edited by Lifeseeker; 01-07-2012 at 02:33 AM.

  2. #2
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: type mismatch on cell contents. Cell.clearcontents

    Instead try:
    Please Login or Register  to view this content.
    I usually avoid using "CELL" as a variable name. I also re-dimmed ce as a Range instead of an Object.

  3. #3
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: type mismatch on cell contents. Cell.clearcontents

    Hi Paul,

    Please Login or Register  to view this content.
    nothing happens...I wonder if it has to do with how values on the range F2:J40 are entered. They are populated automatically by clicking buttons. (so they are not manually entered into the spreadsheet). But this doesn't mean it is the reason for why code doesn't work?

  4. #4
    Forum Expert OnErrorGoto0's Avatar
    Join Date
    12-30-2011
    Location
    I DO NOT POST HERE ANYMORE
    MS-Off Ver
    I DO NOT POST HERE ANYMORE
    Posts
    1,655

    Re: type mismatch on cell contents. Cell.clearcontents

    Just as a test, if you run
    Please Login or Register  to view this content.
    do you see the message?
    Good luck.

  5. #5
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: type mismatch on cell contents. Cell.clearcontents

    OnError's suggestion was going to be next... are your macros enabled? Or did they somehow get disabled (via code or not enabling them when opening the workbook)?

  6. #6
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: type mismatch on cell contents. Cell.clearcontents

    Please see the attached....this is pretty frustrating as there is no problem with the code, but it's not running...(the message box is running, but no cell contents are cleared...)

    Thanks

    Button is to the right hand side
    Attached Files Attached Files

  7. #7
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,330

    Re: type mismatch on cell contents. Cell.clearcontents

    try
    Please Login or Register  to view this content.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  8. #8
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: type mismatch on cell contents. Cell.clearcontents

    I downloaded your workbook, and noticed that the only values in F2:J40 were zeroes. (0, 0%, etc.). This macro won't remove any of those since it's explicitly checking for only cells that are not equal to 0 and clearing those. If you want it to clear cells that *are* 0, change "<>0" to "=0".

    I entered a few non-zero values into that range, clicked the button and it worked just fine - leaving blank cells wherever those values were entered.

  9. #9
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: type mismatch on cell contents. Cell.clearcontents

    ah I see.

    So if I wanted to remove both 0 and 0% AND non zeros( so as long as a cell has something in it), I would use an OR statement or something like that?

    By the way, in practice, I only want to apply this on the F column to clear the formula from formula bar. (The F2:J40 is just small test).

    This F column will contains both 0 and actual numbers. I want to have a macro that removes all of them.

    I had thought that a simple like this would do the trick, but guess not.

  10. #10
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: type mismatch on cell contents. Cell.clearcontents

    Only removed 0 but not other numbers from column F. In practice, I want this to be done only on col F, which may contain BOTH 0 and other numbers.

  11. #11
    Forum Expert Paul's Avatar
    Join Date
    02-05-2007
    Location
    Wisconsin
    MS-Off Ver
    2016/365
    Posts
    6,885

    Re: type mismatch on cell contents. Cell.clearcontents

    If you simply want to clear the formulas/contents of all cells in column F (from F2 downward), just use
    Please Login or Register  to view this content.

  12. #12
    Valued Forum Contributor
    Join Date
    10-21-2011
    Location
    Canada
    MS-Off Ver
    Excel 2010
    Posts
    513

    Re: type mismatch on cell contents. Cell.clearcontents

    ahh I see I see.....

    Thank you Paul...I've learned so much from you just today....

    I still have lots to learn even in Excel...

+ 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