How do I move data from one worksheet to another...

bt2086

New Member
Joined
May 31, 2012
Messages
33
How do I move data from one worksheet to another... I have a worksheet called "Chart" which has 2 columns of list. 1st column has students' ages & 2nd column has corresponding students' names. I'd like to move students who are in their 20s (there are students who are in their teens, 20s, 30s, and 40s) to worksheet called "Data" by using if statement, but I want only their names shown on "Data" worksheet.
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Hi bt2086,

Try this:

Code:
Option Explicit
Sub Macro2()

    'http://www.mrexcel.com/forum/showthread.php?642879-How-do-I-move-data-from-one-worksheet-to-another

    Dim rngCell As Range
        
    Application.ScreenUpdating = False
    
    For Each rngCell In Sheets("Chart").Range("A2:A" & Sheets("Chart").Range("A" & Rows.Count).End(xlUp).Row)
        If rngCell.Value >= 20 And rngCell.Value <= 29 Then
            Sheets("Chart").Range("B" & rngCell.Row).Copy _
                Destination:=Sheets("Data").Range("A" & Sheets("Data").Range("A" & Rows.Count).End(xlUp).Row + 1)
        End If
    Next rngCell
    
    Application.ScreenUpdating = True

End Sub

HTH

Robert
 
Upvote 0

Forum statistics

Threads
1,203,762
Messages
6,057,219
Members
444,915
Latest member
getrdon24

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top