+ Reply to Thread
Results 1 to 9 of 9

Delete rows based on the value of a cell

  1. #1
    Registered User
    Join Date
    05-30-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    68

    Delete rows based on the value of a cell

    Hi all,TLC test.xlsm

    Please I need help to complete my work, I have a code that makes a button to add cells (rows) under a reference cell, and I need to find a way to delete the added cells (rows) and keep only the rows above the reference cell if I change the value of another cell “key cell”. I attached a simulation of the file and fully described what I need help with.Thanks in advance


    Emma_B

  2. #2
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Delete rows based on the value of a cell

    Hi Emma,
    try it (attached)
    Attached Files Attached Files

  3. #3
    Registered User
    Join Date
    05-30-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Delete rows based on the value of a cell

    Thanks nilem, I got an error with the file you sent, this happen when I change the value in cell C4! I integrated the code you wrote with the original one so that it works to creat new addresses with new letters . However the main problem does exist (deleting all addresses (rows) after address C in case I cahnged the value of the cell C4. I rewrote what I need in a different way so hope it will be clear now. see that attached file.

    Moreover, I would like to ask you to explain the this piece of code for me?
    Please Login or Register  to view this content.
    is'nt it the code for giving new letters to the neww addresses?


    Regards
    Emma_B

    THe file attached again

    TLC test1.xlsm

  4. #4
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Delete rows based on the value of a cell

    "is'nt it the code for giving new letters to the neww addresses?"
    Yeah, right

    try again
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    05-30-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Delete rows based on the value of a cell

    Fantastic, thats and epic solution thanks a lot. I still need you to explain this piece of code in words for me because I want to apply in in other files that have other number of cells and rows and letters. i.e. the last address might not be C it could be K. I appreciate if you can write how to I read/interpret this code (specially the Chr part).

    Please Login or Register  to view this content.

    Regards
    Emma_B

  6. #6
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Delete rows based on the value of a cell

    I just tried to bind row number of the range "New_address" (i = [New_address].Row) and a character code (a number that represents a particular character in a set, such as the ANSI character set).
    Try it to understand better
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-30-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Delete rows based on the value of a cell

    Hi,

    Sorry again I could not ask a clear question . I understand the character code i.e what number represents which character, what I wanted to know is how do you address the target cell and tell the code to go and look at the letter there and produce the next letter in the alphabet in the new cell (in the new created address). in other words how do you calculate the "distance" number of rows & columns between the the cell that has the letter and the one that shall have the next letter?. what is the (/ 6 + 16) in the code?

    /Emma_B

  8. #8
    Forum Expert nilem's Avatar
    Join Date
    10-22-2011
    Location
    Ufa, Russia
    MS-Off Ver
    2013
    Posts
    3,377

    Re: Delete rows based on the value of a cell

    ok, I'll try to explain
    if row number of the range "New_address" is 28, we should get 68 (Chr(68) returns "D")
    if row number of the range "New_address" is 34, we should get 69 (Chr(69) returns "E")
    if row number of the range "New_address" is 40, we should get 70 (Chr(70) returns "F")
    etc.
    and I came up with a formula for this sequence of numbers
    (28-16)/6+66=68
    (34-16)/6+66=69
    (40-16)/6+66=70
    (34-16)/6+66=69
    and so on

    Sorry, my English is not the best

  9. #9
    Registered User
    Join Date
    05-30-2013
    Location
    Sweden
    MS-Off Ver
    Excel 2010
    Posts
    68

    Re: Delete rows based on the value of a cell

    That is brilliant solution Thank you very much

+ 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 certain rows based on value in another cell
    By angelk in forum Excel General
    Replies: 1
    Last Post: 07-30-2012, 02:38 PM
  2. Delete rows based on cell content
    By scaffdog845 in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 05-06-2010, 07:34 PM
  3. Delete Rows based on cell value and then Insert rows alternatively with a formula
    By acsishere in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-11-2008, 04:27 PM
  4. Delete rows based on a cell value in the row
    By Dave in forum Excel General
    Replies: 7
    Last Post: 03-14-2006, 02:50 PM
  5. Delete rows based on Cell name
    By gmunro in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-25-2005, 09:15 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