+ Reply to Thread
Results 1 to 3 of 3

Macro to delete rows based on a value using user input box

  1. #1
    Registered User
    Join Date
    11-28-2019
    Location
    UK
    MS-Off Ver
    365
    Posts
    3

    Smile Macro to delete rows based on a value using user input box

    Hi all!

    *EDIT - Forgot to mention that the times/values will be in decimals...not sure if that is relevant, but thought to add in!*

    I am looking for a macro that will help me with this scenario.

    So I have a bunch of data that looks like this (I know the values look weird, please bear with me):

    Time Rate Force
    10 0.032 -10.55818
    20 0.065 -10.53982
    30 0.100 -10.53187
    40 0.132 -10.55818
    50 0.200 -10.53982
    60 0.299 -10.53187
    70 0.332 -10.55818

    I want to delete some of the data rows from the table/file that I do not need. I want to create a macro that will pop up with a user input box, and I want to look at column A and decide from what time onwards is the data that I want to keep, and the macro will delete rows before that time.

    to make it simpler:

    > look at column A
    > see from which value I want to keep data
    > e.g. choose 50s
    > input 50 into input box
    > macro will delete the rows prior to 50s.

    Does this make sense? and is this doable? I tried to do it myself from scratch, but my vba knowledge is poor and I am mainly googling. I have a sample of something I have been trying to work on but a bit confusedif I am going the correct way.

    Please Login or Register  to view this content.
    Thank you!!!!!
    Last edited by AditiM; 10-16-2020 at 01:28 PM.

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Macro to delete rows based on a value using user input box

    Very easily done

    Select any row and then run this macro

    You have a choice. Either enter a Value or simply click OK to delete the rows before the active cell.


    Please Login or Register  to view this content.
    Last edited by mehmetcik; 10-16-2020 at 01:12 PM.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    11-28-2019
    Location
    UK
    MS-Off Ver
    365
    Posts
    3

    Re: Macro to delete rows based on a value using user input box

    Thanks! :D the code worked!

    Quick question, is there a way to just delete the values rather than the rows itself? I have my layout set out in such a way that it contains graphs and titles on the data, when I run this code, it will remove them both. For reference, I will attach an example spreadsheet.

    Thanks again!
    Attached Files Attached Files
    Last edited by AditiM; 10-16-2020 at 01:39 PM.

+ 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] VBA to delete rows based on user input
    By Roux11 in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 05-27-2020, 11:40 AM
  2. Macro to Copy/Insert Copied cells based on user input # of rows/formatting rules
    By gaker10 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-04-2015, 11:42 AM
  3. Macro to Delete Row based upon User Input Box value
    By Mike7591 in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 09-18-2013, 10:02 AM
  4. Macro to Copy Rows based on User Input
    By CharterJP in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-24-2012, 06:13 PM
  5. [SOLVED] Macro based on User input to Insert X amount of rows - Need advanced help
    By BuzzOffSweetheart in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-19-2012, 07:06 PM
  6. Automatically Add/Delete rows based on user input but check current table row count
    By clemsoncooz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-31-2011, 11:39 AM
  7. Delete rows based on user input
    By Militia in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-10-2009, 06:33 AM

Tags for this Thread

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