+ Reply to Thread
Results 1 to 4 of 4

Macro for deleting all the data from the sheet except the first row

  1. #1
    Registered User
    Join Date
    06-03-2023
    Location
    New Jersey
    MS-Off Ver
    MS 3655
    Posts
    29

    Macro for deleting all the data from the sheet except the first row

    Hi

    I tried to record a macro for deleting all the data from the sheet except the first row but it does it for a few initial columns and 3 to 4 columns remain just as they are.

    So, I want to modify that macro so all the data except the first column gets deleted.

    The macro is written as:

    Sub Clear_Data()
    '
    ' Clear_Data Macro()
    '
    '
    Range("A2").Select
    Range(Selection, Selection.End(x1Down)). Select
    Range(Selection, Selection.End(x1Down)). Select
    Range(Selection, Selection.End(x1ToRight)). Select
    Range(Selection, Selection.End(x1ToRight)). Select
    Range(Selection, Selection.End(x1 ToRight), Select
    Range(Selection, Selection.End(x1 ToRight)), Select
    Range(Selection, Selection.End(x1 ToRight), Select
    Range(Selection, Selection.End(x1 ToRight), Select
    Selection.ClearContents
    End Sub

    Please advise.

    Regards

  2. #2
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,542

    Re: Macro for deleting all the data from the sheet except the first row

    At one point you say "except the first Row" and later "Except the first Column".
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    Experience trumps academics every day of the week and twice on Sunday.

  3. #3
    Registered User
    Join Date
    06-03-2023
    Location
    New Jersey
    MS-Off Ver
    MS 3655
    Posts
    29

    Re: Macro for deleting all the data from the sheet except the first row

    Sorry it is except the first row

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,443

    Re: Macro for deleting all the data from the sheet except the first row

    @nupurs250

    Administrative Note:

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

+ 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. Replies: 0
    Last Post: 11-07-2022, 02:35 PM
  2. [SOLVED] Sub CallMacro to copy data to dest sheet is deleting formula in destination sheet
    By 962371 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-02-2017, 12:38 PM
  3. [SOLVED] Deleting sheet macro
    By niukvba in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-06-2014, 04:09 AM
  4. [SOLVED] Deleting rows from sheet 1 when table on sheet 2 does not have the data anymore
    By charscribbles in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-03-2014, 09:39 PM
  5. [SOLVED] Help with Macro to delete data without deleting formulas on same sheet
    By Pi* in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-11-2014, 11:58 PM
  6. Errors in my formulas in sheet 1 when deleting data in sheet 2
    By Sucha304 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-03-2012, 02:22 AM
  7. Macro to deleting SSN from each Sheet
    By dziw in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-25-2007, 09:06 AM

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