PDA

View Full Version : Range("Cells(a,b),Cells(a,b)").Select is not work



clif
04-22-2012, 08:02 PM
Why the below code is not work? Thank you very much!



Sub Macro18()

Dim a As Integer
Dim ba As Integer

For a = 0 To 30
b = a + 3

Sheets("Apr").Select
Range("Cells(37,b),Cells(56,b)").Select
Selection.Copy
Sheets("abc").Select
Cells(2 + a, 20).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=True

Next a

End Sub

HaHoBe
04-22-2012, 08:47 PM
Hi, clif,

shouldn´t it read
Range(Cells(37, b), Cells(56, b))Ciao,
Holger

Bob Phillips
04-23-2012, 12:28 AM
Why not just

Range("B37:B56")

Also you can avoid the selecting


Sub Macro18()
Dim a As Long
Dim b As Long

For a = 0 To 30

b = a + 3

Worksheets("Apr").Range("B37:B56)").Copy
Worksheets("abc").Cells(2 + a, 20).PasteSpecial Paste:=xlPasteValues
Next a
End Sub