我正在尝试创建一个宏,它将删除空格,对它们进行排序,并将任何小于1000000的数字转换为文本。
我能够让他们删除空格,但我无法将数字更改为文本。
Option Explicit
Sub Promo1()
Worksheets("PROMO#1").Range("A:A").Select
Selection.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
Range("A:R").Sort key1:=Range("A:A"), order1:=xlAscending, key2:=Range("O:O"), order2:=xlAscending
Dim productcode As Range
Dim cells As Range
Set productcode = Range("A1:A1000")
For Each cells In productcode
If cells.Value < 999999 Then
cells.Value = CDec(cells)
Else
End If
Next cells
End Sub
谁能帮我?
将数字更改为文本的简单方法:
For Each cell In ProductCode
If cell.Value < 999999 Then
cell.Value = "'" & cell.Text
End If
Next Cells
预先挂起(如果这是正确的单词)可见值的单引号。这假设cell
是Range变量。
同
If cells.Value < 999999 Then
Excel将强制空白为0
小于999999并且CDec(cells)
返回0
如果要跳过空白,请将该检查添加到IF
If cells.Value < 999999 and cells <> "" Then