![]() |
How do I get this macro to start the search in the second row
I have the following code. It loops through and searches each row in sheet1.
If it find and asterick in column M on sheet 1, it will append the row to sheet 2. First, How can I get it to start the search loop at row 2 because row 1 is the header information. Second, how to I get it to paste only information from columns A, B, F, G, and H to sheet 2. Public Sub CopyStuff() Dim wksFrom As Worksheet Dim wksTo As Worksheet Dim rngFound As Range Dim rngFoundAll As Range Dim rngToSearch As Range Dim strFirstAddress As String Set wksFrom = Sheets("Sheet1") 'copy from worksheet Set wksTo = Sheets("Sheet2") 'copy to worksheet Set rngToSearch = wksFrom.Columns("M") 'Asterick ("*") in this column denotes a change or addition Set rngFound = rngToSearch.Find(What:="*", _ LookAt:=xlWhole, _ LookIn:=xlValues, _ MatchCase:=True) If rngFound Is Nothing Then MsgBox "Asterick (" * ") was not found" Else strFirstAddress = rngFound.Address Set rngFoundAll = rngFound Do Set rngFoundAll = Union(rngFound, rngFoundAll) Set rngFound = rngToSearch.FindNext(rngFound) Loop Until rngFound.Address = strFirstAddress rngFoundAll.EntireRow.Copy _ wksTo.Cells(Rows.Count, "A").End(xlUp).Offset(0, 0) End If End Sub -- jsm |
All times are GMT +1. The time now is 10:29 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com