+ Reply to Thread
Results 1 to 3 of 3

macro to retain certain Data

Hybrid View

  1. #1
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    macro to retain certain Data

    I have various items in Col F


    I have tried to write code to retain "Fixed asset ledger" in Col f from row 2 onwards and all the other rows are to be deleted. The code deletes everything from row 2 onward



    I have attached my workbook . Please test & amend code


     Sub Retain_Fixed_asset_Ledger()
        Dim rngTable As Range
        Dim lngIndex As Long
        Dim rngCheck As Range
        Dim varOffset As Variant
        Const strKey As String = "Fixed*"
        
        With ActiveSheet
            Set rngTable = Range(.Range("F2"), .Range("F" & .Rows.Count).End(xlUp))
        End With
    
        For lngIndex = rngTable.Row + 2 To rngTable.Rows.Count + rngTable.Row Step 3
            Set rngCheck = rngTable(lngIndex - rngTable.Row - 1).Resize(3)
            varOffset = Application.Match(strKey, rngCheck, 0)
           
        Next lngIndex
        
        With rngTable
            .SpecialCells(xlCellTypeVisible).EntireRow.Delete
            
        End With
    End Sub

    Your assistance is most appreciated
    Attached Files Attached Files
    Last edited by flupsie; 07-05-2018 at 03:04 AM.

  2. #2
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: macro to retain certain Data

    Sub test()
        With Cells(1).CurrentRegion
            .AutoFilter 6, "<>Fixed asset Ledger"
            .Offset(1).EntireRow.Delete
            .AutoFilter
        End With
    End Sub

  3. #3
    Spammer
    Join Date
    08-20-2012
    Location
    Canada
    MS-Off Ver
    2007
    Posts
    221

    Re: macro to retain certain Data

    thanks for your help Jindon


    Code fairly simple

+ 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] Macro to retain only certain items
    By flupsie in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-16-2017, 07:00 AM
  2. Replies: 2
    Last Post: 07-11-2014, 08:13 PM
  3. Macro to retain a formula and overwrite when needed
    By lefeu in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 04-09-2013, 07:25 AM
  4. How to retain data
    By pareng_kitz in forum Excel General
    Replies: 0
    Last Post: 11-03-2012, 09:39 PM
  5. Need macro to retain the entire row data between two headers in a particular column
    By Nikkishr in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-30-2012, 06:41 PM
  6. Macro to save to PDF and retain 11x17 landscape
    By Dougl in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-07-2012, 06:52 PM
  7. Retain the Value of a Variable in Macro
    By blueperfume300 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-07-2007, 04:19 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