2016-09-14 22 views
0

我不能修复此代码,让Else错误,而不If否则,如果在命令部分

Sub aRefreshData() 
If Worksheets("Control tab").Range("$I$2").Value = "OFF" Then MsgBox "Enable Connection before refresh" 
Else 
ActiveWorkbook.Connections("server DB").Refresh 
End If 
End Sub 
+2

欢迎后,#2。你需要添加一个语言标签(这看起来像VBA),[格式化你的代码](http://stackoverflow.com/help/formatting),并扩大你的问题的解释 – JGreenwell

回答

1

你错过了“:”否则

Sub aRefreshData() 
If Worksheets("Control tab").Range("$I$2").Value = "OFF" Then 
    MsgBox "Enable Connection before refresh" 
Else: 
    ActiveWorkbook.Connections("server DB").Refresh 
End If 
End Sub 
+0

非常感谢! –

+0

很高兴帮助。如果你接受它作为回答,这将是一件好事:) – Techidiot

相关问题