Selecting Range will not work

Brad McIntyre 101 Reputation points
2021-06-07T18:48:19.133+00:00

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 Visual Basic for Applications
Office Visual Basic for Applications
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Visual Basic for Applications: An implementation of Visual Basic that is built into Microsoft products.
1,502 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Brad McIntyre 101 Reputation points
    2021-06-07T19:00:41.503+00:00

    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

    0 comments No comments

  2. Brad McIntyre 101 Reputation points
    2021-06-07T19:05:22.243+00:00

    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

    0 comments No comments

  3. Brad McIntyre 101 Reputation points
    2021-06-07T19:12:02.483+00:00

    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

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.