Macro Help

kishengiggs1

New Member
Joined
Jun 21, 2011
Messages
23
Hi all,

I am new at Macros. I just need a little help on automating a process that I usually do manually. I am sure its a very simple macro but any help will be appreciated.

I would like the macro to

check if column AB=1 or 2, on "Sheet1" then copy the whole row for that column and paste in on a diff worksheet called "Sheet2"

thanks
Kishen
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
This Code Will Copy The Rows But Make Sure To Select Sheet1 Before Running The Macro
Code:
Sub CopyRow()
Dim LR As Long
LR = Cells(Rows.Count, 28).End(xlUp).Row
For Each Cell In Range("AB1:AB" & LR)
    If Cell.Value = 1 Or Cell.Value = 2 Then
       Cell.EntireRow.Copy
       Sheets("Sheet2").Select
       If Range("A1") = "" Then
          Range("A1").PasteSpecial
          Application.CutCopyMode = False
       Else
          Range("A" & LR + 1).PasteSpecial
          Application.CutCopyMode = False
       End If
    End If
    sheets("sheet1").select
Next
End Sub
ZAX
 
Upvote 0

Forum statistics

Threads
1,223,719
Messages
6,174,087
Members
452,542
Latest member
Bricklin

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