Macros to copy alternate rows to anothersheet
Closed
sg
-
28 Apr 2010 à 07:03
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 - 28 Apr 2010 à 08:27
rizvisa1 Posts 4478 Registration date Thursday 28 January 2010 Status Contributor Last seen 5 May 2022 - 28 Apr 2010 à 08:27
Related:
- Macros to copy alternate rows to anothersheet
- Excel online macros - Guide
- How to copy macros from one workbook to another - Guide
- How to delete rows in word - Guide
- How to repeat rows in excel - Guide
- Unlock excel vba and excel macros - Guide
1 response
rizvisa1
Posts
4478
Registration date
Thursday 28 January 2010
Status
Contributor
Last seen
5 May 2022
766
28 Apr 2010 à 08:27
28 Apr 2010 à 08:27
Sub copyrow()
Dim lMaxRowsCopyFrom As Long
Dim lMaxRowCopyTo As Long
Dim lCopyRow As Long
Dim lStartRow As Long
Dim sCopyFrom As String
Dim sCopyTo As String
lStartRow = 2
sCopyTo = "Sheet2"
sCopyFrom = "Sheet1"
lMaxRowsCopyFrom = Sheets(sCopyFrom).Cells(Rows.Count, "A").End(xlUp).Row
lMaxRowCopyTo = Sheets(sCopyTo).Cells(Rows.Count, "A").End(xlUp).Row
If lMaxRowCopyTo = 1 Then lMaxRowCopyTo = 2
For lCopyRow = lStartRow To lMaxRowsCopyFrom Step 2
Sheets(sCopyTo).Range(lMaxRowCopyTo & ":" & lMaxRowCopyTo) = Sheets(sCopyFrom).Range(lCopyRow & ":" & lCopyRow).Value
lMaxRowCopyTo = lMaxRowCopyTo + 1
Next lCopyRow
End Sub