Moving Data

S

SRS

Hello NG,

Does anybody have a macro that will move data from one sheet to another
based on a set criteria?

For example

A 690
B 690
C 715
D 720
E 720

I would run a macro and it would copy entries A and B to a tab named 690,
etc.

Thanks in advance
 
T

Tom Ogilvy

Dim rng as Range
Dim wks as Worksheet
Dim cell as Range
set rng = Range(Cells(2,1),Cells(2,1).End(xldown))

for each cell in rng
On error resume next
set wks = Worksheets(format(cell.value,"@"))
On Error goto 0
if not wks is nothing then
cell.EntireRow.Copy _
destination:=wks.cells(rows.count,1).End(xlup)(2)
end if
Next

Wil split out your data to sheets based on the value in column B

This is a start - you can enrich it to do what you need.

If you only want to do 690, then put in a if statement

Dim rng as Range
Dim wks as Worksheet
Dim cell as Range
set rng = Range(Cells(2,1),Cells(2,1).End(xldown))

for each cell in rng
if clng(cell.Value) = 690 then
On error resume next
set wks = Worksheets(format(cell.value,"@"))
On Error goto 0
if not wks is nothing then
cell.EntireRow.Copy _
destination:=wks.cells(rows.count,1).End(xlup)(2)
end if
End if
Next


Code is untested, but represents a workable approach.
 
Top