选择动态范围 [英] Selecting dynamic range

查看:44
本文介绍了选择动态范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用Excel动态选择单元格?我很想知道如何制作一个能做到这一点的宏.我希望它根据其他单元格的值选择某些单元格.例如,ik要选择A1到A20.ik希望通过在一个单元格中键入1并在另一个单元格中键入20来做到这一点.

Is it possible to have excel dynamic select cells? I'd love to know how to make a macro that does that. I want it to select certain cells based on the value of other cells. For example, ik want to select A1 to A20. And ik want to do that by simply typing 1 in a cell and 20 in another.

我在vba中尝试了此代码

I tried this code in vba

昏暗的例子作为范围设置示例=范围("A1:A20")

Dim example as range Set example = range ("A1:A20")

示例.选择.

它可以工作,但是我希望A1和A20可以更改,以便我可以选择不同的范围

It works, but i want the A1 and A20 to be changeable so i can select different ranges

有可能吗?如果不是,最接近的是什么?非常感谢!

Is that possible? And if not, what is the closest thing to it? Many thanks!

推荐答案

我假设开始行在B1中,结束行在B2中.

I assume start row is in B1 and end row is in B2.

Set example = Range(Cells(Cells(1, 2).Value, 1), Cells(Cells(2, 2).Value, 1))

这篇关于选择动态范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆