Results 1 to 3 of 3

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

Threaded View

  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.

    Sub ChopTopData()
    
    'Dim TopChop As String   ' this is the number that the user inputs
    Dim TopChop As Integer
    
    Dim c As Range              ' this is therange of cells that will be lokked at to be deleted?
    
    Let TopChop = InputBox("Enter Top range cut off value to be deleted")
        If TopChop = vbNullString Then Exit Sub
            For Each c In Range("B:B")
            
            If c = TopChop Then c.EntireRow.Delete
            If c < TopChop Then
            
            
    
    
    
    End Sub
    Thank you!!!!!
    Last edited by AditiM; 10-16-2020 at 01:28 PM.

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