Sub kkk()
Dim i As Integer
Dim j, m As Integer
Dim Temp As String
Dim myapp As New Application
Dim sh As Worksheet
Application.ScreenUpdating = False
Temp = "C:\Documents and Settings\kkk\桌面\板块资金\“9.14”.xls"
myapp.Visible = False
Set sh = myapp.Workbooks.Open(Temp).Sheets(1)
For i = 2 To 12
j = 2 + (i - 2) * 6
m = j + 1
Sheets("资金流向").Cells(“106” j) = sh.Cells(i, 2)
Sheets("资金流向").Cells(“106”, m) = sh.Cells(i, 4)
Next
myapp.Quit
Set sh = Nothing
Set myapp = Nothing
Application.ScreenUpdating = True
End Sub
其中打上双引号的地方是我想通过文本窗口输入然后改变的
'添加文本框TextBox1输入文件名称,TextBox2输入行号,命令按钮CommandButton1Private Sub CommandButton1_Click()Dim i As IntegerDim j, m As IntegerDim Temp As StringDim myapp As New ApplicationDim sh As WorksheetDim rw As LongDim fn As Stringfn = TextBox1 & ".xls"rw = CLng(TextBox2)Debug.Print rwApplication.ScreenUpdating