+ Reply to Thread
Results 1 to 6 of 6

Clearcontesnts not working as expected.

  1. #1
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Clearcontesnts not working as expected.

    So I have a piece of code from a macro that works perfectly in another workbook.
    Now I copied that code in my new workbook but the outcome is not as in the original workbook.

    This is the code:
    Please Login or Register  to view this content.
    Now in the original it indeed cleared the contents. Totally empty.

    However in the new book it cleares the contents but it shows a 0 (zero)....not what i want.
    Also try in the settings to uncheck "show 0 when value is zero".
    Indeed the cell looks empty but when you select the cell you still see the 0.....

    As said in the original workbook this was not the case. Totally empty also when the cell was selected.

    Anybody know what is going on?
    Thanks.

  2. #2
    Registered User
    Join Date
    08-10-2012
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Clearcontesnts not working as expected.

    Hope this Helps, Change the Range Accordingly.

    Dim lprow3 As Long
    With ActiveSheet
    lprow3 = .Cells(.Rows.Count, "A").End(xlUp).Row
    End With
    For k = 2 To lprow3
    If Range("E" & k).Value = "EUR" Then
    Range("AB" & k).ClearContents
    End If
    Next k

  3. #3
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Clearcontesnts not working as expected.

    Why cant we write a one line code to delete the zero after your code? will that help?
    Regards
    Parth

    I appreciate your feedback. Hit * if u Like.
    Rules - http://www.excelforum.com/forum-rule...rum-rules.html

  4. #4
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: Clearcontesnts not working as expected.

    Thanks but same result.
    And probably I could have te zeros afterwards delete again....

    But the point of this all is that the code works in one workbook and changes in another workbook the contents of the cell to 0 instead of cleaning it.
    Apart from finding this anoying I also would like to understand what could cause this behaviour in excel.

  5. #5
    Forum Contributor
    Join Date
    07-26-2012
    Location
    Netherlands
    MS-Off Ver
    Excel 2016 Office 365 ProPlus
    Posts
    822

    Re: Clearcontesnts not working as expected.

    Well I found it......

    It was a piece of code after the clearcontents that caused to show zeros.
    The code made absolute values of the cells in that column (ABS).....so that caused to show zeros after it was clearcontentst.... woops...

  6. #6
    Valued Forum Contributor Parth007's Avatar
    Join Date
    12-01-2014
    Location
    Banglore
    MS-Off Ver
    2010
    Posts
    879

    Re: Clearcontesnts not working as expected.

    i actually did write a single line code to delete the left zeros in it :D

+ 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] CountIfS not working as expected
    By rschoenb in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-12-2014, 11:45 PM
  2. String not working as expected
    By WilyOne in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-21-2011, 08:44 AM
  3. [SOLVED] IF statement is not working as expected?
    By Aland2929 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-31-2009, 02:02 PM
  4. IF statement not working as expected?
    By Aland2929 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-30-2009, 07:03 AM
  5. [SOLVED] Lookup Not working as expected
    By trumpy81 in forum Excel - New Users/Basics
    Replies: 5
    Last Post: 06-30-2005, 03:05 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