0
我有一个列有不同的数值。一些具有格式:如何计算单元格中的整数并在VBA中进行排序?
0.56
1.52
,部分格式,如:
6,352.00
要做到在Excel计算我想替代"," with ""
当数格式是这样6,352.00和所有其他替代"." with ",".
所以结果我应该得到:
0,56
1,52
6352,00
然后将它们从最大值分类到最小值。
我试图写一个VBA代码(这不是真的正确),也许有人可以帮助吗?
Sub ChangeFormat1()
Dim lngNumberOfCharacters As Long
Set ws4 = ActiveWorkbook.Sheets("atm_hh")
ws4.Select
Columns("C:C").Select
lngNumberOfCharacters = Len("C:C")
If lngNumberOfCharacters > 8
Selection.Replace What:=",", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
Else
Selection.Replace What:=".", Replacement:=",", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
End If
ActiveWorkbook.Worksheets("atm_hh").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("atm_hh").Sort.SortFields.Add Key:=Range("C1"), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("atm_hh").Sort
.SetRange Range("A2:D66842")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
可能重复(HTTP:/ /stackoverflow.com/questions/25970985/excel-formula-to-delete-a-character-from-a-string-then-replace-another-character) – 2014-10-01 09:34:29
我试过了,使用公式:'= SUBSTITUTE(SUBSTITUTE( A1,“,”,“”),“。”,“,”)',但它给了我一个错误 – Ale 2014-10-01 10:24:52
首先使用一个独特的字符从','改变为'^'例如,然后运行'。 ''到','然后'^'到'。' – 2014-10-01 10:27:41