Copy and Paste

Paleo

New Member
Joined
Jan 4, 2005
Messages
43
I have a problem. I need to look upon a worksheet and find cells that have a "JF" expression on them. After that I need to select their hole row, cut them, create a new worksheet and paste the cutted cells on it.

I did it till the cut and sheets.add phase but I am not being able to paste the content.

May someone help me please?????
 
Hi Zack,

yes I am using the code you posted. I will point you on which line I am getting to error by a <- sign. Okay?

Code:
Option Explicit

Sub TestForMrE()
    Dim aNome As String, Nova As String, filterRng As Range, nommes As String
    While (Len(nommes) > 3) Or nommes = ""
        nommes = InputBox("Type month's name with 3 characters", "Report Month", _
            "jan, feb, mar, apr, mai, jun, jul, aug, sep, oct, nov, dec")
    Wend
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    aNome = "can_" & LCase(nommes)
    Nova = "NC_" & LCase(nommes)
    ActiveSheet.Name = aNome
    Sheets.Add
    ActiveSheet.Name = Nova
    With Sheets(aNome)
        '.Range("A1").EntireRow.Copy Sheets(Nova).Range("A1")
        Set filterRng = .Range("A1", .Range("D65536").End(xlUp))
        With filterRng
            .AutoFilter field:=1, Criteria1:="=NC"
            .SpecialCells(xlCellTypeVisible).Copy Sheets(Nova).Range("A2") <-
            .SpecialCells(xlCellTypeVisible).Delete
            .Cells(1).EntireRow.Insert
        End With
        Sheets(Nova).Range("1:1").Copy .Range("1:1")
    End With
    Sheets(Nova).Activate
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
End Sub

The error is code 1004 and this is the line I mentioned to change from A2 to A1. The interesting thing is that its actually copying the rows, just not deleting them but the error is thrown in the copy row. isnt it strange?
 
Upvote 0

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,215,884
Messages
6,127,564
Members
449,385
Latest member
KMGLarson

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