+ Reply to Thread
Results 1 to 5 of 5

Help with Macro to delete data without deleting formulas on same sheet

  1. #1
    Forum Contributor
    Join Date
    03-17-2013
    Location
    USA, IL
    MS-Off Ver
    Excel 2010
    Posts
    121

    Help with Macro to delete data without deleting formulas on same sheet

    Good evening,

    I was hoping you could assist me with editing the below macro that deletes/clears content data range in a sheet depending on time period run;
    Sub Update_Format()

    application.ScreenUpdating = False

    'This macro pulls data to the different databases based on what time is AM/PM)
    Dim x As Variant, Y As Variant, Z As Variant

    If Time < 0.5 Then
    [AB15].Select
    ActiveCell.Value = Now
    [AB16].ClearContents
    Worksheets("DB PM").Select
    Range("Data_Clean_PM").ClearContents
    Worksheets("DB AM").Select
    Range("Format_Pull_AM").Select
    Else
    [AB16].Select
    ActiveCell.Value = Now
    Worksheets("DB PM").Select
    Range("Format_Pull_PM").Select
    End If
    x = EssVConnect(Null, Null, Null, "Tryprappro9s4.yhu.ping.Com", "Format", "Format")
    x = EssVSetSheetOption(Null, 9, "0")
    x = EssVSetSheetOption(Null, 11, True)
    Z = EssVRetrieve(Null, Selection, 1)

    Worksheets("DB Weekly").Select
    Range("Weekly_Pull").Select

    Z = EssVRetrieve(Null, Selection, 1)
    Y = EssVDisconnect(Null)

    ' this is a temporal way to disconnect all. Improve when time allows.
    '======
    Worksheets("DB PM").Select
    Y = EssVDisconnect(Null)
    Worksheets("DB AM").Select
    Y = EssVDisconnect(Null)
    '======

    Worksheets("High Level").Select
    [W3].Select

    application.ScreenUpdating = True

    End Sub


    Basically what happens in the mornings and especailly in the pm is when I run the macro it clears all contents in that specific sheet but what i am hoping you could help me with is that I have some formulas in that same sheet as well that I am hoping the edited macro would skip and only delete constant or data that is not a formula. The data that is deleted span from E3 to UI125 and I have a formula in a row from E100 all through to IU100.
    I am no expect but maybe you can assist with editing the macro to delete two separate ranges so it skips the row with formulas (E100:UI100)

    Thank you for your time.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Help with Macro to delete data without deleting formulas on same sheet

    Hi, Pi*,

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    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, it also maintains VBA formatting.

    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



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)

    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Contributor
    Join Date
    03-17-2013
    Location
    USA, IL
    MS-Off Ver
    Excel 2010
    Posts
    121

    Help with Macro to delete constant data without deleting formulas on same sheet

    Good evening,

    My apologies for not using code tags around my code.

    I was hoping you could assist me with editing the first part of the below macro that deletes/clearscontents in a range of cells in a sheet depending on time of day it is run. Basically when I run this macro in the mornings and especially in the afternoon it clears all the contents in a specific sheet (DB AM and DB PM), however, I am hoping you could help me editing it so it skips rows that contain formula in the same sheets it deletes data.

    I am no expect but perhaps the edited macro can delete constants only and leave rows with formulas on the DB AM and DB PM sheets. The data that is deleted ranges from E3 to UI125 and I have a formula in a row from E100 all through to IU100.

    Thank you for your time.

    Please Login or Register  to view this content.

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,197

    Re: Help with Macro to delete constant data without deleting formulas on same sheet

    Hi, Pi*,

    why do you start a new thread instead of editing your post at http://www.excelforum.com/excel-prog...ame-sheet.html

    Try
    Please Login or Register  to view this content.
    instead of
    Please Login or Register  to view this content.
    Besides: I think you have far too much Selects in your code.

    Ciao,
    Holger

  5. #5
    Forum Contributor
    Join Date
    03-17-2013
    Location
    USA, IL
    MS-Off Ver
    Excel 2010
    Posts
    121

    Re: Help with Macro to delete data without deleting formulas on same sheet

    The intended moderation request for this thread was fulfilled but inadvertently re-posted on a new thread with similar heading.

    My apologies.

    This issue was solved.

    Thanks.

+ 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. Delete chartobject without deleting ALL charts on sheet
    By blh in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-14-2014, 07:01 AM
  2. Loop to Delete worksheets stops after deleting one sheet...
    By booDaddy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-17-2014, 05:12 PM
  3. [SOLVED] Macro to delete formulas extended past data set
    By mcranda in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 06-25-2013, 05:49 PM
  4. 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
  5. [SOLVED] how do I delete numbers without deleting formulas
    By Emmaus junkie in forum Excel General
    Replies: 1
    Last Post: 10-08-2005, 05: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