Macro for copying entire raw

M

Mac

How can I code a VBA macro to copy entire raw of a perticuler text in column B and paste in the sheet named Output? I mean macro should filterout the raws of a name say mac and then copy only that filtered raw and paste to the sheet named mac

Any help is appreciated
Thanks.
 
T

Tom Ogilvy

Dim rng as Range
set rng = cells.Find("mac")
if not rng is nothing then
rng.EntireRow.copy Destination:=worksheets("Output"). _
Cells(rows.count,1).End(xlup)(2)
end if

If you want to copy it to Mac instead of output, then change output to mac

If you want to look in only one column, then change cells to columns(3) for
example.

--
regards,
Tom Ogilvy

Mac said:
How can I code a VBA macro to copy entire raw of a perticuler text in
column B and paste in the sheet named Output? I mean macro should filterout
the raws of a name say mac and then copy only that filtered raw and paste to
the sheet named mac.
 
M

Mac

Thanks Tom for your superfast response. I could not imagine that somebody can be so fast atleast in helping others.
There are two problems in the code.
1. Macro should go through all the raws in the sheet, search for the name1 in col B and all the raws having name1 in col B
to be copied in sheet already there in that name.
2. Then macro will search for the next name in col B, anain copy the raws having that name in col B in the sheet already there
in that name.
3. Simmilarly it should search for all the names in the col B and copy it to the sheet already there in that name.

Pl note that the col B can have the same names repeated many times( This is name of our salesman)
I tried to modify your code to get the above result but failed to assign the cell content to the destination.
Request a bit more help please.

Thanks again,
Mac.


----- Tom Ogilvy wrote: -----

Dim rng as Range
set rng = cells.Find("mac")
if not rng is nothing then
rng.EntireRow.copy Destination:=worksheets("Output"). _
Cells(rows.count,1).End(xlup)(2)
end if

If you want to copy it to Mac instead of output, then change output to mac

If you want to look in only one column, then change cells to columns(3) for
example.

--
regards,
Tom Ogilvy

Mac said:
How can I code a VBA macro to copy entire raw of a perticuler text in
column B and paste in the sheet named Output? I mean macro should filterout
the raws of a name say mac and then copy only that filtered raw and paste to
the sheet named mac.
 
D

Dave Peterson

You may want to look at Debra Dalgleish's site:

http://www.contextures.com/excelfiles.html

There are a couple of files you may want to steal from:

Create New Sheets from Filtered List -- uses an Advanced Filter to create
separate sheet of orders for each sales rep visible in a filtered list; macro
automates the filter. AdvFilterRepFiltered.xls 35 kb

Update Sheets from Master -- uses an Advanced Filter to send data from
Master sheet to individual worksheets -- replaces old data with current.
AdvFilterCity.xls 55 kb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top