我可以CMD使用以下代码从Windows中的SFTP下载文件:
WinSCP.com
# Connect to the host and login using password
open user:pw@address
# get all the files in the remote directory and download them to a specific local directory
lcd C:\Users\xx\Desktop
get *.xlsx
# Close and terminate the session
exit
Run Code Online (Sandbox Code Playgroud)
我在线搜索,发现可以将这些代码放在bat文件中并使用
Call Shell("cmd.exe /c C:\Users\xx\Desktop\WinSCPGet.bat", 1)
Run Code Online (Sandbox Code Playgroud)
但是,仅WinSCP.com执行bat文件的第一行。它将弹出cmd窗口,显示此内容,而不执行其他任何操作。

如何一次执行所有行?
谢谢
如果我运行下面的代码
dt<-data.table(col1=c(0,1,2),col2=c("a","b","c"),col3=c("aa","ab","cc"))
setkey(dt,col1)
dt1<-data.table(a=c(1,2))
dt[dt1]
Run Code Online (Sandbox Code Playgroud)
我得到了以下结果
col1 col2 col3
1: 1 b ab
2: 2 c cc
Run Code Online (Sandbox Code Playgroud)
但是,预期的结果是
a col1 col2 col3
1: 0 a aa
2: 1 1 b ab
3: 2 2 c cc
Run Code Online (Sandbox Code Playgroud)
如何获得预期的结果?
我想使用VBA来获取活动单元格的值。通过在线搜索,我发现了以下代码。
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Sheets("sheet1").Range("Selection").Value = Cells(ActiveCell.Row, ActiveCell.Column).Value
End Sub
Run Code Online (Sandbox Code Playgroud)
但是,我必须将这些代码放在工作表“ sheet1”下。如果我有三张纸,sheet1, sheet2, and sheet3我需要复制上面的代码,并稍作修改将它们分别粘贴在这三张纸下面。
有什么方法不需要将代码放在单独的工作表中(也许就在ThisWorkbook下),而无论激活了哪一个工作表,我仍然可以获取activecell的值。
谢谢