Excel VBA, getting range from an inactive sheet

前端 未结 3 2082
走了就别回头了
走了就别回头了 2020-11-21 06:29

This script works fine when I\'m viewing the \"Temp\" sheet. But when I\'m in another sheet then the copy command fails.. It gives a \"Application-defined or object-defined

3条回答
  •  情话喂你
    2020-11-21 06:56

    I encountered a problem like this myself: I was trying to search through a separate worksheet to see if the color of a cell matched the color of a cell in a list and return a string value: if you are using .Cells(row, column), you only need this: Sheets("sheetname").Cells(row, column) to reference that range of cells.

    I was looping through a block of 500 cells and it works surprisingly quickly for me.

    I have not tried this with .Copy, but I would assume it would work the same way.

提交回复
热议问题