question

BradMcIntyre-8213 avatar image
0 Votes"
BradMcIntyre-8213 asked BradMcIntyre-8213 answered

Selecting Range will not work

Thank you for taking the time to read my question.

I have the following code. The first Range(cells(),cells()).select works, but the second one will not. I'm at a total loss as to why. Any help would be great.

 Range(Cells(1, WBSCol), Cells(x, y)).Select
 Selection.Copy
 Sheets("ByStartDate").Select
 ActiveSheet.Range("A4").Select
 Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats
 ActiveSheet.Range("A4").Select
 Selection.PasteSpecial Paste:=xlPasteFormats
    
 Range(Cells(9, 1), Cells(x + 4, y - 2)).Select


"1004, Select Method of Range class failed"

Thanks!

office-vba-dev
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


For which values of x and y did it fail?

0 Votes 0 ·
BradMcIntyre-8213 avatar image
0 Votes"
BradMcIntyre-8213 answered

Hi Viorel-1

Thank you for your reply.

I'm not sure what you mean, sorry.

Range(Cells(9, 1), Cells(x + 4, y - 2)).Select = Range(Cells(9,1),Cells(57,43)).Select

So I don't see why selecting this range is not valid.

Thanks

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

BradMcIntyre-8213 avatar image
0 Votes"
BradMcIntyre-8213 answered

I just tried this... and got the same error:

Range("A1").Select

On the activesheet... ByStartDate .... I have just pastedspecial the values and formats so there is an active range that is highlighted. Does that have anything to do with it?

Thanks

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

BradMcIntyre-8213 avatar image
0 Votes"
BradMcIntyre-8213 answered

I ran a test in a brand new workbook and the code works fine, so it must be my workbook. I tried a open and repair but that has not fixed anything.

Thanks

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.