Hi,
I have a problem with my vba code. I have two similar codes, only the ranges are different. But for the first range excel will not give an error. And for the second range excel give this error:
run-time error '1004':
Method 'Range' of object '_Worksheet' failed.
I don't understand thisbecause both ranges are containing as much multiple ranges in it. The only different is that the first range contains less caracters because a range is like R7:AC7 and the second range is like AG7:AR7.
Can anyone help me with this?
Thanks a lot.
This codes works
For i = 5 To 255 Step 7
For j = 21 To 29 Step 1
If Sheet2.Cells(i, j).Value = "" Then
Else
Sheet2.Range(Sheet2.Cells(i, j), Sheet2.Cells(i + 5, j)).Copy
Sheet11.Select
Sheet11.Range("R7:AC7,R22:AC22,R37:AC37,R52:AC52,R67:AC67,R82:AC82,R97:AC97,R112:AC112,R127:AC127,R142:AC142,R157:AC157,R172:AC172,R187:AC187,R202:AC202,R217:AC217,R232:AC232,R247:AC247,R262:AC262,R277:AC277,R292:AC292,R307:AC307,R322:AC322,R337:AC337,R352:AC352").SpecialCells(xlCellTypeBlanks).Cells(1).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
End If
Next
Next
same code with this range instead doesn't works:
Sheet11.Range("AG7:AR7,AG22:AR22,AG37:AR37,AG52:AR52,AG67:AR67,AG82:AR82,AG97:AR97,AG112:AR112,AG127:AR127,AG142:AR142,AG157:AR157,AG172:AR172,AG187:AR187,AG202:AR202,AG217:AR217,AG232:AR232,AG247:AR247,AG262:AR262,AG277:AR277,AG292:AR292,AG307:AR307,AG322:AR322,AG337:AR337,AG352:AR352").SpecialCells(xlCellTypeBlanks).Cells(1).Select
When I choose debug this range is selected in yellow.
Kind regards,
Bookmarks