+ Reply to Thread
Results 1 to 4 of 4

Macro To Clear Cell Contents From Top To Bottom Of A Column

  1. #1
    Registered User
    Join Date
    12-09-2012
    Location
    Butterworth, Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Macro To Clear Cell Contents From Top To Bottom Of A Column

    I would greatly appreciate if anyone could help me with the following.

    I have a macro that would clear numerical contents of each cell in column A every one minute (initiated by the click of a command button linked to this macro).

    However, this macro begins to clear contents from the last cell in column (i.e A65536) and moves upwards.

    (a) What I actually need is for the reverse to happen, starting to clear cells beginning A1(or a specified cell) and move downwards every minute till A65536.

    (b) Also, I would want the same to happen to cells in columns B till AB.

    Thank you very much in advance.

    My code is as follows

    Option Explicit
    Public dTime As Date

    Sub ClearCell()
    Dim c As Range
    For Each c In Range("A65536").End(xlUp)
    If IsNumeric(Val(c)) Then c.ClearContents
    Next c
    Call StartTimer
    End Sub


    Sub StartTimer()
    dTime = Now + TimeValue("00:01:00")
    Application.OnTime dTime, "ClearCell", Schedule:=True
    End Sub

    Sub StopTimer()
    On Error Resume Next
    Application.OnTime dTime, "ClearCell", Schedule:=False
    End Sub
    Last edited by kany; 01-01-2013 at 02:24 AM.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Macro To Clear Cell Contents From Top To Bottom Of A Column

    Try something like this. Change the sheet name to suit.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    12-27-2012
    Location
    Portland,OR
    MS-Off Ver
    Excel 2010
    Posts
    49

    Re: Macro To Clear Cell Contents From Top To Bottom Of A Column

    This might work
    Range("A1:AB65536").FormulaR1C1 = clearcontents
    Try Adding that to you or the code above with your timer this works from top to bottom.
    Last edited by chriswiec; 01-01-2013 at 01:48 AM.

  4. #4
    Registered User
    Join Date
    12-09-2012
    Location
    Butterworth, Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Macro To Clear Cell Contents From Top To Bottom Of A Column

    I wish to extend my sincere thanks to both AlphaFrog and Chriswiec for the prompt and kind assistance given to me. I tried and the two methods worked great, just as what I wanted. If not for you guys and Excel Forum, i would be scratching my head for next countless days as what I've doing for the past few days.

    Again, thank you so much for making me learn something new about macro programming and completing my project. And, not forgetting, Happy New Year 2013 to both of you as well as the Excel Forum family.

    Warm regards.

+ 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