• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

code doesn't work plus copy cell to another cells twice in another workbook

aleksandra123

New Member
Hi I have below code. It seems work however I cannot get any result

Sub cpypstalt()
Dim s1 As Workbook, s2 As Workbook
Set s1 = Workbooks("Book1.xlsm")
Set s2 = Workbooks("Book2.xlsm")
Dim lr As Long, lr2 As Long
Dim i As Long
lr = s1.Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
lr2 = 1
Application.ScreenUpdating = False
For i = 1 To lr
s2.Sheets("Sheet1").Range("A" & lr2) = s1.Sheets("Sheet1").Range("A" & i).SpecialCells(xlCellTypeVisible)
lr2 = lr2 + 2
Next i
Application.ScreenUpdating = True
End Sub

I used Special Cells (xlCellTypeVisible) as I need to copy only filtered data. However it doesn't work.

On top of that, I am trying to create macro which copy one cell A1 in let's say Workbook Book1 and copy twice to workbook Book2 and then return and copy cell A2 and paste again in the Book2 twice under the first pasting.

Anyone can help me?

Many Thanks!
 
Hi !

Thanks to use appropriate code icon next time !

Directly use Range.Copy method (see in VBA inner help)
as working only with visible cells, so SpecialCells is useless …
 
Back
Top