ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   looping and copying (https://www.excelbanter.com/excel-programming/347599-looping-copying.html)

Juuljus

looping and copying
 
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


Juuljus

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

Juuljus


Jef Gorbach

looping and copying
 

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).Offs et(1, 0)

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

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

"Juuljus" wrote in message
oups.com...
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





All times are GMT +1. The time now is 10:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com