我希望使用Excel做一些更高级的事情。从本质上讲,我希望根据单独表格中输入的值创建一份全面的叙述性报告。
我希望创建的报告中的某些部分始终是相同的。然而,我想在叙述中改变的是:学生成绩,学生姓名和学生性别。
我已经提供了一个样例excel文件的链接,我希望实现(实际的报告将接近9-10页)。简而言之,我有一个表(表1),其中将包括针对特定学生的测试分数摘要。我希望创建一个按钮,它将根据这些值生成一个叙述,并填写代词将根据性别更改的学生的姓名(“学生姓名”和“性别”字段都可以找到,并将根据需要在表1中进行编辑)。
例如,如果我输入学生姓名为"Mike“,性别为”男性“,并单击"generate report”按钮,则会在整个报告中填写这些值。
我假设这将通过VBA完成,但不确定从哪里/如何开始这一过程。
这是我到目前为止所知道的:
Sub Add2Formula()
' Add text
For Each c In Selection
c.Activate
ActiveCell.FormulaR1C1 = "report text here" & ActiveCell.Formula
Next c
End Sub我遇到的问题是让表格和叙述性报告相互对话(这样报告就会根据另一个学生的更新值动态变化)。
我运行的是Windows 10和Microsoft Office Pro Plus (2019)。
任何建议/建议都是非常感谢的。
Sample Workbook
Darko
发布于 2020-09-23 09:13:51
试一下,
Sub test()
Dim shpRpt As Shape
Dim Ws As Worksheet
Dim myString As String
Dim sName As String, sTest1 As String, sTest2 As String
Dim sTest3 As String, sTest4 As String
Dim sGender As String
Set Ws = ActiveSheet
Set shpRpt = Ws.Shapes("Report")
With Ws
sName = .Range("a12")
sTest1 = .Range("b4")
sTest2 = .Range("c4")
sTest3 = .Range("b5")
sTest4 = .Range("c5")
If .Range("c12") = "male" Then
sGender = "His"
Else
sGender = "Her"
End If
End With
myString = "The Math was administered for " & sName & "'s assessment. The Math is a standardized measure of development for Sample High School," _
& "and places a strong emphasis on child-friendly, developmentally appropriate features and tasks. The WISC-V is an individually" _
& "administered assessment that reports scores as Raw Scores (RS) with a mean (average) of 100 and standard deviation of 15," _
& "with most people scoring between 85 and 115. Tests administered in the school environment do not capture every aspect of math ability;" _
& " however, these tests are useful in predicting how intense instruction needs to be in order for the individual to master academic content. " _
& sName & "'s Overall Math Test performance on the school-based measure of cognitive processing abilities falls within the Average range (RS=" & sTest1 & ";PR=" & sTest2 & "). " _
& vbCrLf & vbCrLf _
& "Algebra is a branch of mathematics dealing with symbols and the rules for manipulating those symbols. On this subtest," _
& "Mike scored within the Significantly Below Average range (RS=" & sTest3 & ";PR=" & sTest4 & "). " & sGender & " scores varied quite drastically throughout the assessment."
shpRpt.TextFrame2.TextRange = myString
End Subhttps://stackoverflow.com/questions/64018827
复制相似问题