+ Reply to Thread
Results 1 to 6 of 6

Conditionally deleting some sells in a column.

  1. #1
    Registered User
    Join Date
    01-04-2010
    Location
    Amsterdam, Netherland
    MS-Off Ver
    Excel 2003
    Posts
    43

    Conditionally deleting some sells in a column.

    I need a simple macro to conditionally delete some se data in a column.

    For example.

    -----------------------------------------------------------------------------------------------

    1) For Each c In Range("B2:B65536")
    2)
    3) if c = ("Verz.Oud.pens." "Ber.Oud.pens." Left(c, 5) = "kateg" "Tar" "Mut.code" "Stdnr" "contract")
    4)
    5) Than delite c
    6) End If
    7) Next c

    ----------------------------------------------------------------------------------------------------------

    The problem in my macro is that I can't make C checking for these values and after deleting them ..
    Last edited by Sokol; 04-15-2013 at 05:46 AM.

  2. #2
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Conditionally deleting some sells in a column.

    Could you describe more clearly exactly which values you want to delete?

  3. #3
    Registered User
    Join Date
    01-04-2010
    Location
    Amsterdam, Netherland
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Conditionally deleting some sells in a column.

    The values that are in parentheses for c

    if c= ("Verz.Oud.pens." or "Ber.Oud.pens." or Left(c, 5) = "kateg" or "Tar" "Mut.code" or "Stdnr" or "contract")

    Then delete c

    if c is not equal to all these values ("Verz.Oud.pens." "Ber.Oud.pens." Left(c, 5) = "kateg" "Tar" "Mut.code" "Stdnr" "contract") ,

    do nothing.

  4. #4
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Conditionally deleting some sells in a column.

    Try:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    01-04-2010
    Location
    Amsterdam, Netherland
    MS-Off Ver
    Excel 2003
    Posts
    43

    Re: Conditionally deleting some sells in a column.

    It works.

    Thanks again...

    In mean time I’m trying to adapt your previous macros in order to filter some data from a row data input, but I think that I’m missing something. The idea is to implement the macro below..... I do not know what is going wrong..

    " Dim bottomA As Integer
    bottomA = Range("A" & Rows.Count).End(xlUp).Row
    Dim y As Integer
    For y = bottomA To 2 Step -1
    If IsDate(y) Then
    y.Offset(0, 3).Value = a.Value
    if cells ( y, 2) = "U" or Cells ( y, 2) = "I" then
    y.offset (0, 4).Value = a.Value
    End If
    Next y "

    Sorry if you see a "beginer" mistake, .... But is true I'm a real beginner in VBA...

  6. #6
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 2013
    Posts
    7,820

    Re: Conditionally deleting some sells in a column.

    Hi Sokol. I'm glad the code worked out for you. Try the code below. I'm guessing at what you would like to do so it may not work for you. If it doesn't work, please give me a detailed description of exactly what you want to do or even better, post a copy of your file.
    Please Login or Register  to view this content.
    When you are posting any code, remember to use code tags.. Highlight your code and then click the '#' sign on the top menu.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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