Moving Data

  • Thread starter Thread starter SRS
  • Start date Start date
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
 
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.
 

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