Home |
Search |
Today's Posts |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro: search word, select row, copy.
Finds a word in a worksheet??
dim FoundCell as Range dim WhatToFind as string whattofind = "SomeWordHere" with worksheets("sheet9999") set foundcell = .cells.find(what:=whattofind, _ after:=.Cells(.Cells.Count), _ LookIn:=xlValues, _ lookat:=xlWhole, _ searchorder:=xlByRows, _ searchdirection:=xlNext, _ MatchCase:=False) end with if foundcell is nothing then 'the word wasn't found else foundcell.entirerow.interior.colorindex = 3 'what color do you want?? foundcell.entirerow.copy _ destination:=someothercellincolumnA end if ==== Untested and uncompiled. Raul wrote: I'm tryingo to write a macro in excel which: -Finds a word in the file -Selects the row which contains the word -Changes the color of the row -Copy the entire row I have this: Cells.FindNext(After:=ActiveCell).Activate With Selection.Interior .ColorIndex = 6 .Pattern = xlSolid End With Selection.Copy End Sub but i can't seem to figure out how to select only the row which contains the word. If I select the entire row, the macro will always copy that same row [' Rows(4)' will select always row 4. 'Rows' will select all the rows...] Comments? -- Dave Peterson |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Search Excel and copy result into word | Excel Programming | |||
macro to intsert a word using the "Find" command to search for a word | Excel Programming | |||
macro to search for & select ranges to sum | Excel Programming | |||
search for a specific word and copy the word and the preceeding words until a comma | Excel Programming | |||
select all & copy in word from macro in excel | Excel Programming |