Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
I want to search "if cell a1 start with .. " | Excel Discussion (Misc queries) | |||
Sub Macro vrs Function Macro Auto Start | Excel Discussion (Misc queries) | |||
How do I start a search | New Users to Excel | |||
Lookup with search range start based on position of last blank lin | Excel Worksheet Functions | |||
Start Macro / Stop Macro / Restart Macro | Excel Programming |