strTmp = sheet.Cells(i, j) If strTmp = "" Then Exit For r(i - 1, j - 1) = strTmp改为: r(i - 1, j - 1) = sheet.Cells(i, j) 因为双循环里面的要判断很多次,中间变量赋值又没什么意义
row = sheet.UsedRange.Rows.Count col = sheet.UsedRange.Columns.Count ReDim r(row - 1, col - 1) with sheetFor i = 1 To sheet.UsedRange.Rows.Count -->row For j = 1 To sheet.UsedRange.Columns.Count-->col strTmp = .Cells(i, j) If strTmp = "" Then Exit For r(i - 1, j - 1) = strTmp Next j Next i endwith
可以把数据用SQL语句写到ACCESS数据库
也可以把EXCEL当做数据库使用
我的意思是我执行上面的for循环,就需要半多分钟的时间,我觉得很慢,初用vb还不知如何提高读取效率,请问,有别的什么好办法么?
If strTmp = "" Then Exit For
r(i - 1, j - 1) = strTmp改为:
r(i - 1, j - 1) = sheet.Cells(i, j)
因为双循环里面的要判断很多次,中间变量赋值又没什么意义
col = sheet.UsedRange.Columns.Count
ReDim r(row - 1, col - 1)
with sheetFor i = 1 To sheet.UsedRange.Rows.Count -->row
For j = 1 To sheet.UsedRange.Columns.Count-->col strTmp = .Cells(i, j) If strTmp = "" Then Exit For
r(i - 1, j - 1) = strTmp
Next j
Next i
endwith
Then Exit For
这个代码就有问题,若是空值不能退出,也要进行相应的赋值
http://download.csdn.net/source/369462