我对VBA的体验非常有限。以下VBA代码运行SAS存储过程并将结果放在Excel电子表格中。存储的进程提示“EUID”设置为返回值5555.如何修改代码以便从电子表格中的单元格(例如单元格B1)中提取提示值,而不是在代码中定义?我希望最终用户能够在单元格中键入EUID值,按下按钮以运行宏,并返回数据集。谢谢您的帮助。
Sub InsertStoredProcessWithPrompts()
Dim sas As SASExcelAddIn
Set sas = Application.COMAddIns.Item("SAS.ExcelAddIn").Object
Dim prompts As SASPrompts
Set prompts = New SASPrompts
prompts.Add "EUID", "5555"
Dim a1 As Range
Set a1 = Sheet5.Range("A1")
sas.InsertStoredProcess "/User Folders/Stored Process 1", c1, prompts
End Sub
答案 0 :(得分:1)
你可以试试这个:
Sub InsertStoredProcessWithPrompts()
Dim sas As SASExcelAddIn
Set sas = Application.COMAddIns.Item("SAS.ExcelAddIn").Object
Dim prompts As SASPrompts
Set prompts = New SASPrompts
prompts.Add "EUID", activesheet.cells(1,2).value 'This is cell B1
Dim a1 As Range
Set a1 = Sheet5.Range("A1")
sas.InsertStoredProcess "/User Folders/Stored Process 1", c1, prompts
End Sub