简体   繁体   English

在模块 VBA 中添加表单控件

[英]Adding a form control within module VBA

I've tried doing multiple searches, but may be wording incorrectly giving me info that doesn't apply.我尝试进行多次搜索,但可能是措辞不正确,给我的信息不适用。

I have a macro that parses through data, creates a new workbook and within that, a new worksheet.我有一个宏可以解析数据,创建一个新的工作簿,并在其中创建一个新的工作表。 I want to be able to throw a form control or some sort of option for the user to add more data after the fact.我希望能够为用户抛出一个表单控件或某种选项,以便在事后添加更多数据。 Follow a similar example below to get a better understanding.按照下面的类似示例进行操作以获得更好的理解。

Say I have a workbook that I call "analyzer" and takes some input, formats it and also adds a summary tab.假设我有一个工作簿,我称之为“分析器”,并接受一些输入、格式化并添加一个摘要选项卡。 For instance, I'm a business and have all transactions made in my small store for a given month in a spreadsheet, .txt file etc. This is the input that "analyzer" takes in and formats.例如,我是一家企业,并且在电子表格、.txt 文件等中,我的小商店在给定月份进行了所有交易。这是“分析器”接受并格式化的输入。

"Analyzer" has a form control button on it and when you click it, it pops open a dialog box for you to select whatever months you want to analyze. “分析器”上有一个表单控件按钮,当您单击它时,它会弹出一个对话框,您可以选择要分析的月份。 Let's say its March.让我们说它的三月。 When I click on that button, I select January and February, it creates a new workbook, we'll call "Month_eval", formats each month in it's own worksheet and then adds a summary worksheet at the end for a "quick glance" view.当我点击那个按钮时,我选择了一月和二月,它会创建一个新的工作簿,我们称之为“Month_eval”,在它自己的工作表中格式化每个月,然后在最后添加一个摘要工作表以供“快速浏览”视图. Now I have this workbook, "Monthly_eval" that has three worksheets, Jan, Feb and Summary, but no real easy way to add say March or any additional months and append them to it or the summary worksheet.现在我有了这个工作簿“Monthly_eval”,它有三个工作表,一月、二月和摘要,但没有真正简单的方法来添加三月或任何其他月份并将它们附加到它或摘要工作表。

What I would like to is add a form control button to the "summary" tab/worksheet to basically analyze more months of data and append to "Month_eval".我想要的是向“摘要”选项卡/工作表添加一个表单控件按钮,以基本上分析更多月份的数据并附加到“Month_eval”。 The problem is this doesn't exist until I run the "Analyzer" workbook.问题是在我运行“分析器”工作簿之前这不存在。 I can't figure out how to phrase/search this to get relevant results.我不知道如何用词组/搜索来获得相关结果。 I think I should be able to get it from there by assigning a procedure to the button click.我想我应该能够通过为按钮单击分配一个过程来从那里获得它。

I apologize if this is asked multiple times.如果多次询问此问题,我深表歉意。 If there is something relevant or almost identical, please post and I'll close the thread.如果有相关或几乎相同的内容,请发布,我将关闭线程。

So from data in WBX you want to create a new workbook WBY with N worksheets containing monthly analysis, and this WBY will have the functionality to append additional data from WBX?因此,您希望从 WBX 中的数据创建一个新的工作簿 WBY,其中包含 N 个包含每月分析的工作表,并且该 WBY 将具有附加来自 WBX 的其他数据的功能?

I think maybe you will need to create a class for this WBY.我想也许你需要为这个 WBY 创建一个类。

Why not have a Summary workbook (SWB) and an analysis workbook (AWB).为什么没有摘要工作簿 (SWB) 和分析工作簿 (AWB)。 When you want to analyse the data you just export it from SWB to AWB and do your formulas and view it, instead of generating a new workbook everytime?当您想分析数据时,您只需将其从 SWB 导出到 AWB 并执行您的公式并查看它,而不是每次都生成新的工作簿?

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

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