如何从VBA中的范围创建列表? [英] How do you create a list from a range in VBA?

查看:116
本文介绍了如何从VBA中的范围创建列表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对VBA很新。我正在尝试创建一个切换按钮,将列表切换到一个范围,然后根据需要返回到列表。我能够做到这两点但是当我将一个项目添加到列表中时,转换为一个范围,然后转换回一个列表,它将我输入的最后一项留下。我尝试使用代码来选择所有单元格,但我不能将它放在正确的位置。

这是我到目前为止:
ActiveSheet.ListObjects.Add(xlSrcRange) ,范围("$ A $ 3:$ AE $ 7"),, xlYes).Name = _
" List1"

我意识到问题是$ AE $ 7( $ 3美元是正确的)但我不知道如何解决它。我已经尝试了2天的开关工作,不知道接下来要做什么。

I am very new to VBA.  I am trying to create a toggle button that switches a list to a range and then back to a list if needed.  I am able to get it to do both but when I add an item to the list, convert to a range and then convert back to a list it leaves off the last items I entered.  I tried to work in a code to select all cells but I must not be putting it in the right place.

This is what I have so far:
ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$3:$AE$7"), , xlYes).Name = _
        "List1"

I realize the problem is the $AE$7 (the $A$3 is correct) but I am not sure how to fix it.  I have tried to work on this for 2 days on and off and have no idea what to try next.

推荐答案

HI,

可以请您详细解释一下您的任务,

我无法理解你的切换按钮功能。

当你点击按钮时,需要采取什么行动再点击什么动作需要什么?

请解释一下,我们可以找到解决方案。

谢谢


Can  you please explain little bit more about your task,

i am not able to understand with your toggle button functionality.

When you click on button , what action is required and after that again when you click what action need ?

Please explain little bit, so we can find solution.

Thanks


这篇关于如何从VBA中的范围创建列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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