怎样遍历Excel中的所有Cell.(50分)

  • 主题发起人 主题发起人 icezs
  • 开始时间 开始时间
I

icezs

Unregistered / Unconfirmed
GUEST, unregistred user!
因要将等于’0’的Cell清空,所以要遍历所有单无格,但只想遍历有数据输入范围的Cell. 请大虾们指点.(在线,等待中.)
 
c:=ExcelApp.Sheets[j].UsedRange.Columns.Count; //列
r:=ExcelApp.Sheets[j].UsedRange.rows.Count; //行
 
谢谢.我试试,行了再给分.
 
Dim i, j As Integer

下面的語句出錯,因沒用過VB,再請WWWB指點
For i = 1 To ActiveSheet.UsedRange.Columns.Count
For j = 1 To ActiveSheet.UsedRange.Rows.Count
If Worksheets("Sheet1").Range.Cells(j, i).Values = 0 Then Selection.ClearContents
Next j
Next i
 
这样也不行
Dim i, j As Integer
For i = 1 To ActiveSheet.UsedRange.Columns.Count
For j = 1 To ActiveSheet.UsedRange.Rows.Count
Worksheets("Sheet1").Activate
If ActiveSheet.UsedRange.Cells(j, i).Values = 0 Then ActiveSheet.UsedRange.Cells(j, i).Values.ClearContents
Next j
Next i
 
你用VB OR DELPHI?
 
解决了,谢谢WWWB.是用VBDim i, j As Integer
For i = 1 To ActiveSheet.UsedRange.Columns.Count
For j = 1 To ActiveSheet.UsedRange.Rows.Count
With ActiveSheet.UsedRange.Cells(j, i)
If .Value = 0 Then .ClearContents
End With
Next j
Next i
 
接受答案了.
 
后退
顶部