使用Excel / VBA生成标题和一组给定的句子 [英] Generating a header and a set of given sentences with Excel / VBA
问题描述
只是要注意,我以前从未使用过这样高级的Excel(实际上,我从来没有使用过任何功能,但是我正在Excel上搜索教程和VBA,而我我在这里询问,以防万一有人知道使用哪些,以及如何有效地使用它们。)
Just to note, I have never used Excel in such an advanced way before (in fact, I have never used any of the functions before... but I'm currently searching for tutorials on Excel online and VBA, and I'm asking here just in case anyone knows better which to use, and how to use them effectively).
我给Excel 5标题列A (也是句子)和 10个句子中,在列B 中生成 3段每个使用 1个标题和每个3个句子。
I'm giving Excel 5 headers in column A (which are also sentences) and 10 sentences in column B to generate 3 paragraphs randomly, each using 1 header and 3 sentences each.
我该如何去实现?我知道Excel有一个RAND()函数,但这似乎只适用于数字...
How do I go about achieving that? I know Excel has a RAND() function, but that seems to only apply to numbers...
更多的是,如果我真的找到解决方案,我会更新
More to come, I'll update if I actually find the solution as well.
推荐答案
如果您的数据位于 A1:A5
和 B1:B10
,然后使用 RANDBETWEEN
If your data was in A1:A5
and B1:B10
of the first sheet then something like this using RANDBETWEEN
Sub GetText()
Dim A
Dim B
A = Sheets(1).Range(Sheets(1).[a1], Sheets(1).[a5])
B = Sheets(1).Range(Sheets(1).[b1], Sheets(1).[b10])
MsgBox A(Application.RandBetween(1, UBound(A)), 1) & " " & B(Application.RandBetween(1, UBound(B)), 1)
End Sub
这篇关于使用Excel / VBA生成标题和一组给定的句子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!