=IF MACRO

Royston31

Board Regular
Joined
Jul 23, 2006
Messages
182
Could anyone tell me how to write this macro?

if the value of any cell in a specifide colonm is 30. then i need it to insert a row below then copy & paste the data from the '30' row into it.

Sure it will be will be easy for you guy's, however im a bit of an amature!!

Kind Regards,

Roy.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
This is written for column A. Simply change all the "A"s to the appropraite column:
Code:
Sub MyCopy()

    Dim i As Long
    For i = Range("A65536").End(xlUp).Row To 1 Step -1
        If Cells(i, "A") = 30 Then
            Rows(i + 1).EntireRow.Insert
            Rows(i).Copy
            Cells(i + 1, "A").Select
            ActiveSheet.Paste
            Application.CutCopyMode = False
        End If
    Next i
    
End Sub
 
Upvote 0
Change
Rows(i).Copy
to
Range(Cells(i, "A"), Cells(i, "P")).Copy
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,937
Members
449,094
Latest member
teemeren

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