+ Reply to Thread
Results 1 to 7 of 7

ClearContents function is clearing unselected cells

  1. #1
    Registered User
    Join Date
    05-16-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    9

    ClearContents function is clearing unselected cells

    I am horrible with VB and I'm struggling to find out why this macro is clearing cells that aren't included in the specified ranges. Here is an example of the code:

    Range("J6:J10", "J12:J17").ClearContents
    Range("J19:J24", "J26:J31").ClearContents
    Range("J33:J38", "J40:J45").ClearContents
    Range("J47:J52", "J54:J59").ClearContents
    Range("J61:J66").ClearContents

    Each of the ranges above are totaled in the row below (totals in 11,18,25,32,39,46,53,60,67). When the macro runs, the totals in rows 11,25,39, and 53 are cleared, even though they aren't included in the range. This is a very large spreadsheet, so changing them individually will take some time. Is there an easier solution to this issue?

    Does this make sense?

    Appreciate any help that I can get.

    Ryan

  2. #2
    Registered User
    Join Date
    08-04-2009
    Location
    Golborne England
    MS-Off Ver
    2013
    Posts
    85

    Re: ClearContents function is clearing unselected cells

    Try this, You were trying to clear two ranges together and they were combining.

    Please Login or Register  to view this content.
    JimBobBowie

  3. #3
    Registered User
    Join Date
    05-16-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: ClearContents function is clearing unselected cells

    Thanks, JimBobBowie. I figured that would work, but is that the easiest option? This is a very large spreadsheet and it will talke quite a while to make all those changes.

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

    Re: ClearContents function is clearing unselected cells

    You can do it in one pass:
    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  5. #5
    Registered User
    Join Date
    05-16-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: ClearContents function is clearing unselected cells

    Quote Originally Posted by romperstomper View Post
    You can do it in one pass:
    Please Login or Register  to view this content.
    And this one won't combine the ranges?

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

    Re: ClearContents function is clearing unselected cells

    Nope. Try it.

  7. #7
    Registered User
    Join Date
    05-16-2013
    Location
    US
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: ClearContents function is clearing unselected cells

    Thanks for the help!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] ClearContents of particular cells if the contents of another cell is deleted
    By nixonquierre in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-08-2015, 04:56 AM
  2. [SOLVED] ClearContents of Merged Cells
    By Bezzie in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-02-2015, 11:26 AM
  3. Mutually Exclusive Tick Marks (Merged Cells / ClearContents issue)
    By mjvoce in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-12-2013, 05:26 AM
  4. ClearContents of a range of cells in on sheets bar 5
    By Juenapa in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-08-2011, 05:18 AM
  5. List box with a divider between selected and unselected
    By yzer19 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-02-2008, 05:17 AM
  6. Macro for selected/unselected checkbox?
    By Orlic in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-25-2008, 02:27 PM
  7. [SOLVED] Delete Unselected Rows
    By Richard in forum Excel General
    Replies: 1
    Last Post: 08-22-2006, 06:35 PM

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