I have a workbook with 351 sheets,
I need a VBA code to copy cells A1 to new column from R5 to R49 (in all sheets)
and Copy from cell B1 to new column from S5 to S49 (in all sheets)
Here is the code that merge everything else (skipping the fist few lines)
I need a VBA code to copy cells A1 to new column from R5 to R49 (in all sheets)
and Copy from cell B1 to new column from S5 to S49 (in all sheets)
Here is the code that merge everything else (skipping the fist few lines)
Code:
Sub Combine()
Dim i As Integer
Dim xTCount As Variant
Dim xWs As Worksheet
On Error Resume Next
LInput:
xTCount = 3
If TypeName(xTCount) = "Boolean" Then Exit Sub
If Not IsNumeric(xTCount) Then
MsgBox "Only can enter number"
GoTo LInput
End If
Set xWs = ActiveWorkbook.Worksheets.Add(Sheets(1))
xWs.Name = "Combined"
Worksheets(2).Range("A1").EntireRow.Copy Destination:=xWs.Range("A1")
For i = 2 To Worksheets.Count
Worksheets(i).Range("A1").CurrentRegion.Offset(CInt(xTCount), 0).Copy _
Destination:=xWs.Cells(xWs.UsedRange.Cells(xWs.UsedRange.Count).Row + 1, 1)
Next
End Sub
Last edited: