Wednesday, April 8, 2015

Copy the data in excel along with format

ActiveWorkbook.Sheets("Anita").Rows("25:" & lastrow).PasteSpecial Paste = xlValues

' PasteSpeical -- should help -- paste speical does not paste the copied content with the format.

' I dont know only this works

ActiveWorkbook.Sheets("Anita").Rows("25:" & lastrow).PasteSpecial -4163


With Worksheets("Sheet1")
    .Range("C1:C5").Copy
    .Range("D1:D5").PasteSpecial _
        Operation:=xlPasteSpecialOperationAdd
End With



' Apply filter and then copy data from one sheet to another in the same excel


Sub addsheet()
Worksheets.Add().Name = "copy1"

ActiveWorkbook.Sheets("Report_from_Clarity").Range("$A$1:$W$223").AutoFilter Field:=1, Criteria1:="PRJ0006FLX" & "*"
lastrow1 = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
MsgBox (lastrow1)

ActiveWorkbook.Sheets("Report_from_Clarity").Rows("1:" & lastrow1).Copy ActiveWorkbook.Sheets("copy1").Rows("1:" & lastrow1)


lastrow2 = Cells.Find("*", [A1], , , xlByRows, xlPrevious).Row
MsgBox (lastrow2)

End Sub

No comments:

Post a Comment