looping and copying

  • Thread starter Thread starter Juuljus
  • Start date Start date
J

Juuljus

Hello,

I need to do a loop, that looks at keywords and then acording to them
copies the data to another sheet.
The table is something like that:

Keyword Text Value Value
key1 dog 1 3
key1 cat 3 4
key2 cow 9 8
key3 fox 44 5

So, the loop should look at the keywords, and then copy the data to
aother range (every keyword has it's own range).

Thanks to everyone who takes the time to reply.

Juuljus
 
Got that. Used Advanced Filter.
If anyone has a better idea, then would be nice so read it.

Juuljus
 
The following snippet might be helpful

<snip>
'move each keyword data to own sheet
Sheets.Add.Name = "keyword1"
Sheets.Add.Name = "keyword2"
Sheets.Add.Name = "keyword3"
'-------
For Each WS In Worksheets(Array("keyword1", "keyword2", "keyword3"))
WS.Range("A1:G1").Value = Sheets("Print").Range("A1:G1").Value 'copy title
row to each new page
Next
'-------
Sheets("inputdata").Activate
For Each cell In Range("G1:G" & Range("G65536").End(xlUp).Row) 'your
keyword column
Select Case cell.Value
Case "keyword1":
cell.EntireRow.Cut
Sheets("keyword1t").Range("A65536").End(xlUp).Offset(1, 0)

Case "keyword2":
cell.EntireRow.Cut
Sheets("keyword2").Range("A65536").End(xlUp).Offset(1, 0)

Case "keyword3":
cell.EntireRow.Cut
Sheets("keyword3").Range("A65536").End(xlUp).Offset(1, 0)
End Select
Next
<end snip>
 

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

Back
Top