2017-02-10 40 views
0

我對VBA的使用經驗非常有限。以下VBA代碼運行SAS存儲過程並將結果放入Excel電子表格中。存儲的進程提示符「EUID」被設置爲返回值5555.如何修改代碼,以便提示的值從電子表格中的單元格(例如單元格B1)中提取,而不是在代碼中定義?我希望最終用戶能夠在單元格中輸入EUID值,按下按鈕運行宏並返回數據集。感謝您的幫助。如何在Excel中鍵入SAS提示值以運行存儲過程?

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 

回答

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 
+0

這工作,謝謝! –

相關問題