Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 11-02-2018, 04:07 PM
jeffreybrown jeffreybrown is offline How to find and select multiple items / values at the same time in Excel Windows Vista How to find and select multiple items / values at the same time in Excel Office 2007
Expert
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

You could do this with a macro! Please test on a copy of your data first.

Code:
Sub Rearrange()
    Dim wsSrc As Worksheet: Set wsSrc = Sheets("Sheet1")
    Dim wsDest As Worksheet: Set wsDest = Sheets("Sheet2")
    Dim lrSrc As Long: lrSrc = wsSrc.Range("A" & Rows.Count).End(xlUp).Row
    Dim lrDest As Long: lrDest = wsDest.Range("A" & Rows.Count).End(xlUp).Row
    
    Const sFormula As String = "=COUNTIF($A$2:$A$#,A2)"
    
    Application.ScreenUpdating = False
    
    wsSrc.Range("A2:A" & lrSrc).Copy wsDest.Range("A" & lrDest + 1)
    
    With wsDest
        .Range("B1").Value = "Hdr"
        lrDest = .Range("A" & Rows.Count).End(xlUp).Row
        With .Range("B2").Resize(lrDest - 1)
            .Formula = Replace(sFormula, "#", lrDest)
            .Value = .Value
        End With
        With .Range("B1", .Range("B" & .Rows.Count).End(xlUp))
            .AutoFilter Field:=1, Criteria1:=">1"
            .Offset(1).EntireRow.Delete
            .AutoFilter
        End With
        .Columns(2).EntireColumn.Delete
    End With

    Application.ScreenUpdating = True
End Sub
Reply With Quote
 

Tags
find-and-replace, select, vlookup



Similar Threads
Thread Thread Starter Forum Replies Last Post
append multiple time values to date in one column sarahafeez Excel 1 09-25-2017 11:01 PM
Select multiple items from a drop down list ConfuddledOne Excel Programming 0 01-30-2017 08:13 PM
Find and replace multiple values, according to table value - excel formula EtanM Excel Programming 3 04-11-2016 01:43 AM
How to find and select multiple items / values at the same time in Excel How do I find and replace multiple items at once? redzan Word VBA 1 05-16-2013 08:25 AM
How to find and select multiple items / values at the same time in Excel Unable to Select Multiple folders in Outlook 2007 Advance Find gregory Outlook 2 04-28-2012 10:53 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:48 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft