作者:zhouib8oevlap | 来源:互联网 | 2023-09-16 09:56
thisisgoingtobesomethingreallyreallysilly!ihavethiscode:这真是太傻了!我有这个代码:PublicSubSort
this is going to be something really really silly! i have this code:
这真是太傻了!我有这个代码:
Public Sub SortMyData()
Dim i As Integer
Dim N_Values As Integer
Dim columnC As String
N_Values = Cells(Rows.Count, 2).End(xlUp).Row
For i = 6 To N_Values
Cells(i, 3).NumberFormat = "0"
If Cells(i, 2).NumberFormat <> "0.0%" Then
Cells(i, 2).NumberFormat = "0.0%"
Cells(i, 2).Value = Cells(i, 2).Value / 100
ElseIf (Cells(i, 3).Value) > 1000000 Then
columnC = (Cells(i, 3).Value / 1000000) & "Mb"
ElseIf Cells(i, 3).Value = Null Then
Cells(i, 3).Value = 0
Else
Cells(i, 2).Value = Cells(i, 2).Value
Cells(i, 3).Value = Cells(i, 3).Value
End If
Next i
End Sub
the code runs fine but the data on the cells does not get changed accordingly. if use debug.print it does print the results that i am looking for. please help!
代码运行正常,但单元格上的数据不会相应更改。如果使用debug.print它会打印我正在寻找的结果。请帮忙!
here is a sample of the data:
这是一个数据样本:
1984000
40000000
230000
230000
230000
1984000
230000
16000000
and this is what the debug.print gives me which is the correct result but not showing on the actual cells (this is just an example and not respective to the data provided):
这就是debug.print给我的正确结果,但没有在实际单元格上显示(这只是一个例子而不是与提供的数据相对应):
2.048Mb
1.984Mb
230kb
16Mb
230kb
16Mb
8Mb
2.007Mb
230kb
i still need to add the IF statement for the kb part but i have got that covered.
我仍然需要为kb部分添加IF语句,但我已经覆盖了它。
1 个解决方案