我想知道如何使用我的代码来清理从第8列开始的0.00的所有内容,并且一旦我完成写入的列跳转到下一行,所以到现在为止我感谢评论和帮助
Dim rng As Range Dim lin,col As Integer
lin = 2
col = 10
Cells(lin, col).Select
Do While ActiveCell.Value <> ""
Do While ActiveCell.Value <> ""
If ActiveCell.Value = ",00" Then
ActiveCell.Value = ""
End If
col = col + 1
Cells(lin, col).Select
Loop
lin = lin + 1
col = 10
Cells(lin, col).Select
Loop
答案 0 :(得分:1)
这是我本来会做的。我会先找到最后一列,然后用数据排成行。我将从col 8循环到最后一个col no数据,然后对于每个col我将循环每一行以找到包含0,00的单元格值。
Option Explicit
'loop from col 8 then go through each line and remove those with 0,00
Sub RemoveZeros()
Dim colNo As Long
Dim rowNo As Long
Dim lastColNo As Long
Dim lastRowNo As Long
Dim ws As Worksheet
'Assuming your sheet name is Sheet1
Set ws = ThisWorkbook.Sheets("Sheet1")
With ws
'Find the last column and row no with data
lastColNo = .Cells(1, .Columns.Count).End(xlToLeft).Column
lastRowNo = .Cells(.Rows.Count, 1).End(xlUp).Row
'loop through each col and row to find those with value 0,00
For colNo = 8 To lastColNo
For rowNo = 1 To lastRowNo
If .Cells(rowNo, colNo).Value = "0,00" Then
.Cells(rowNo, colNo).Value = ""
End If
Next rowNo
Next colNo
End With
End Sub