简体   繁体   English

如何根据单元格值复制不同页面上的范围?

[英]How to copy a range on different pages depending on a cell value?

For example: 例如:

on worksheet1, A1 cell value has data validation for a list, the values of the list are: 在工作表1上,A1单元格值具有列表的数据验证,列表的值为:

-hello -goodbye -你好再见

On worksheet2 i have a data range named "hello" and on worksheet3 i have data range named "goodbye" 在工作表2上,我有一个名为“hello”的数据范围,在工作表3上,我有一个名为“goodbye”的数据范围

What i want is that when i choose from the list hello or goodbye the macro copies the range that is named after the value of A1 cell on worksheet1. 我想要的是,当我从列表中选择你好或再见时,宏会复制在工作表1上以A1单元格的值命名的范围。

Is there a way to do that? 有没有办法做到这一点? i tried making the cell value a string and then use this code: Range("& string &").copy , but the problem is that i dont specify in wich worksheet is the range that i want to copy, so obviously this doesn't work. 我尝试使单元格值成为一个字符串,然后使用此代码:范围(“&string&”)。复制,但问题是,我没有在工作表中指定我要复制的范围,所以显然这不是'工作。

help pls 帮帮忙

If you are applying the `.RefersToRange method, you don't have to go any further with a named range using a Workbook scope. 如果要应用`.RefersToRange方法,则不必使用工作簿范围进一步使用命名范围。

Thisworkbook.names("Hello").referstorange.copy destination:=range("L32")

The destination will have to change to suit your own target and "Hello" should be a reference to your data validation cell but you should get the idea. 目标必须更改以适合您自己的目标, “Hello”应该是对您的数据验证单元的引用,但您应该明白这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM