作者:乔山办公网日期:
返回目录:excel表格制作
通俗点讲with的作用就是简化代码,让代码简洁易懂,百让你不需要输入重复的内容。
例如:
With [A1].RowHeight = 10.ColumnWidth = 15End With相当于[A1].RowHeight = 10[A1].ColumnWidth = 15.
通俗点讲with的作用就是简化代码,让抄代码简洁易懂
让你不需要输入重复的内容
例如百:
With [A1]
.RowHeight = 10
.ColumnWidth = 15
End With
相当于
[A1].RowHeight = 10
[A1].ColumnWidth = 15
省去了输入很多[A1]
也就是说with中以 . 开头的就相当于
WITH后的对象 .什么什度么什么
sub test()
Dim Conn As New ADODB.Connection
Dim strConn As String
Dim strSQL As String
Dim rs As New ADODB.Recordset
strConn = "Provider=sqloledb;Server=192.168.1.111;Database=db2014;Uid=用户名zhidao;Pwd=密码;"
Conn.Open strConn
Max_row = Range("A1").CurrentRegion.Rows.Count
for i=1 to Max_row
strSQL = "select name from sales2014 where id='" & range("A" & i).value & "'"
Conn.Execute strSQL
rs.Open strSQL, Conn, 1, 1
range("B" & i).value= rs(0)
rs.Close
Set rs = Nothing
next i
'关闭专数据库属
Conn.Close
end sub
WITH SHEETS(1)
.cells(1,1,).Value=1
end with