never really concentrated on the VBA although i can feel it is powerful.
i tried a pretty long time to copy 3 columns from 24 sheets to a new sheets. the code is as following. i know it may be stupid but it worked.
the RANGE is powerful with the offset. good. i will use this in later data processing.
Option Explicit
Sub CombineSheets()
Dim i As Integer
', j As Integer, k As Integer, nrows As Integer
'Worksheets("Combined").Select
Dim ws As Worksheet
Set ws = Worksheets("Combined")
For i = 1 To 24
ws.Range(ws.Range("a1").Offset(0, (i - 1) * 3), ws.Range("a1").Offset(65535, i * 3 - 1)).Value = Worksheets("Case" & i).Range("a1:c65536").Value
'For j = 1 To 3
' For k = 1 To nrows
' Cells(k, (i - 1) * 3 + j) = Worksheets("Case" & i).Cells(k, j)
' Next k
'Next j
Next i
End Sub
没有评论:
发表评论