Lau*_*ura 4 excel vba excel-vba
我正在对数据进行排序,并且需要以相同的方式对其进行格式化.输入可能有6 + 18
12
3
5 + 14
20的单元格
我想让它们全部整数.到目前为止我写过这个:
If InStr(data.Cells(x, 8), "+") > 0 Then
'Still trying to figure out this part
Else
calc.Cells((lrcalc + 1), (col + s)).Value = data.Cells(x, 8)
End If
Run Code Online (Sandbox Code Playgroud)
如何将"+"符号左侧的值添加到右侧的值?
那么没有必要检查+
.只需=
在每个单元格中添加一个符号,然后让excel计算它;)
Sub Sample()
Dim lRow As Long, i As Long
Dim ws As Worksheet
'~~> Change this to the relevant sheet
Set ws = ActiveSheet
With ws
'~~> Find last row
lRow = .Range("A" & .Rows.Count).End(xlUp).Row
For i = 1 To lRow
With .Range("A" & i)
.Formula = "=" & .Value
.Value = .Value
End With
Next i
End With
End Sub
Run Code Online (Sandbox Code Playgroud)
截图