可神可神经 可神可神经
关注数: 15 粉丝数: 11 发帖数: 338 关注贴吧数: 11
求助!求给与解释!求帮助改写! 网上找到的一段代码(会发在下面). 目的是:单元格内插入换行符后对数据进行自动编号. 代码如下: ' Reformats a list from a simple delimitation to a numbered list ' Accepts arrays of strings for inList (allowing array formulas) ' numFormat is a standard Excel-style format string (default "0. ") ' inDelimiter is the delimiter in the input list ' outDelimiter is the delimiter for the output list Public Function TO_NUMBERED_LIST(inList As Variant, Optional numFormat As Variant, _ Optional inDelimiter As Variant, Optional outDelimiter As Variant) As Variant Dim i As Integer, j As Integer ' Set default parameters If IsMissing(numFormat) Then numFormat = "0). " If IsMissing(inDelimiter) Then inDelimiter = vbNewLine If IsMissing(outDelimiter) Then outDelimiter = inDelimiter If IsArray(inList) Then ' Must loop through each entry if using as an array formula Dim outList() As Variant ReDim outList(0 To (UBound(inList) - LBound(inList)), 1 To 1) j = 0 For i = LBound(inList) To UBound(inList) If IsError(inList(i, 1)) Then outList(j, 1) = inList(i, 1) Else outList(j, 1) = MakeNumbered(CStr(inList(i, 1)), CStr(numFormat), CStr(inDelimiter), CStr(outDelimiter)) End If j = j + 1 Next TO_NUMBERED_LIST = outList Else TO_NUMBERED_LIST = MakeNumbered(CStr(inList), CStr(numFormat), CStr(inDelimiter), CStr(outDelimiter)) End If End Function ' Helper function to do the actual work of splitting lists, numbering them, and recombining them Private Function MakeNumbered(inList As String, Optional numFormat As String, _ Optional inDelimiter As String, Optional outDelimiter As String) As String Dim i As Integer Dim tokenArr() As String tokenArr = Split(inList, inDelimiter) For i = 0 To UBound(tokenArr) tokenArr(i) = Format(i + 1, numFormat) & tokenArr(i) Next MakeNumbered = Join(tokenArr, outDelimiter) End Function 这应该是一段比较早期的自定义函数. 我也看不懂. 请路过的神仙,帮助解释,也帮助删改一些,保留完整起作用的部分.
求助!求解释!求改写! ' Reformats a list from a simple delimitation to a numbered list ' Accepts arrays of strings for inList (allowing array formulas) ' numFormat is a standard Excel-style format string (default "0. ") ' inDelimiter is the delimiter in the input list ' outDelimiter is the delimiter for the output list Public Function TO_NUMBERED_LIST(inList As Variant, Optional numFormat As Variant, _ Optional inDelimiter As Variant, Optional outDelimiter As Variant) As Variant Dim i As Integer, j As Integer ' Set default parameters If IsMissing(numFormat) Then numFormat = "0). " If IsMissing(inDelimiter) Then inDelimiter = vbNewLine If IsMissing(outDelimiter) Then outDelimiter = inDelimiter If IsArray(inList) Then ' Must loop through each entry if using as an array formula Dim outList() As Variant ReDim outList(0 To (UBound(inList) - LBound(inList)), 1 To 1) j = 0 For i = LBound(inList) To UBound(inList) If IsError(inList(i, 1)) Then outList(j, 1) = inList(i, 1) Else outList(j, 1) = MakeNumbered(CStr(inList(i, 1)), CStr(numFormat), CStr(inDelimiter), CStr(outDelimiter)) End If j = j + 1 Next TO_NUMBERED_LIST = outList Else TO_NUMBERED_LIST = MakeNumbered(CStr(inList), CStr(numFormat), CStr(inDelimiter), CStr(outDelimiter)) End If End Function ' Helper function to do the actual work of splitting lists, numbering them, and recombining them Private Function MakeNumbered(inList As String, Optional numFormat As String, _ Optional inDelimiter As String, Optional outDelimiter As String) As String Dim i As Integer Dim tokenArr() As String tokenArr = Split(inList, inDelimiter) For i = 0 To UBound(tokenArr) tokenArr(i) = Format(i + 1, numFormat) & tokenArr(i) Next MakeNumbered = Join(tokenArr, outDelimiter) End Function
求助!求解释!求改写! ' Reformats a list from a simple delimitation to a numbered list ' Accepts arrays of strings for inList (allowing array formulas) ' numFormat is a standard Excel-style format string (default "0. ") ' inDelimiter is the delimiter in the input list ' outDelimiter is the delimiter for the output list Public Function TO_NUMBERED_LIST(inList As Variant, Optional numFormat As Variant, _ Optional inDelimiter As Variant, Optional outDelimiter As Variant) As Variant Dim i As Integer, j As Integer ' Set default parameters If IsMissing(numFormat) Then numFormat = "0). " If IsMissing(inDelimiter) Then inDelimiter = vbNewLine If IsMissing(outDelimiter) Then outDelimiter = inDelimiter If IsArray(inList) Then ' Must loop through each entry if using as an array formula Dim outList() As Variant ReDim outList(0 To (UBound(inList) - LBound(inList)), 1 To 1) j = 0 For i = LBound(inList) To UBound(inList) If IsError(inList(i, 1)) Then outList(j, 1) = inList(i, 1) Else outList(j, 1) = MakeNumbered(CStr(inList(i, 1)), CStr(numFormat), CStr(inDelimiter), CStr(outDelimiter)) End If j = j + 1 Next TO_NUMBERED_LIST = outList Else TO_NUMBERED_LIST = MakeNumbered(CStr(inList), CStr(numFormat), CStr(inDelimiter), CStr(outDelimiter)) End If End Function ' Helper function to do the actual work of splitting lists, numbering them, and recombining them Private Function MakeNumbered(inList As String, Optional numFormat As String, _ Optional inDelimiter As String, Optional outDelimiter As String) As String Dim i As Integer Dim tokenArr() As String tokenArr = Split(inList, inDelimiter) For i = 0 To UBound(tokenArr) tokenArr(i) = Format(i + 1, numFormat) & tokenArr(i) Next MakeNumbered = Join(tokenArr, outDelimiter) End Function
今天有感 下午时,妻有打电话过来,但是我当时忙于别的事情,没有及时接通。稍后发现,就赶忙的回拨了。 妻说她早上莫名的心揪痛,家人还问她是不是生病云云。去了集市,有妻村里熟识的人告诉她一个事——她的吴姓养父两个月前因癌过世了…… 妻很悲伤,尽管跟她养父一起生活的时间并不是很长,后来也早早地就离开了她的养父。 我也有点难过,因为妻有跟我说起她在养父家生活的日子。不是很幸福,但有被宠爱关怀过。不是很快乐,但也有可以捧腹的故事。 妻曾说,希望今年能回去看看她养父。谁料想,悲欢离合后,那一场离别,竟是永远。 妻是一个可怜人,也是一个懂得感恩的人。 妻曾有两个养父,两个养父都姓吴,是亲兄弟。只是地方不一样,一个在南村,一个在北村。一个车祸离世,一个病葬。 妻说她想回去给养父上坟烧些纸钱。我劝她说不要去了,很久没回去过,就不要再打扰别人了。妻执拗,说会抽出时间来去那边祭拜一下。还要带回相片等附带情感的旧物,免得被扔掉,也可供自已追忆往昔相处时光,给思念留存个寄托处。 那相片,妻印象很深,也给我说过几次。就在妻养父家进门就能看到的堂屋墙上的相框里,是她养父放的,有她。 记忆很美。希望妻再回去的时候,虽然人已经不在了,但相片还要再,方不负最初的美好。 从此,南边一个坟,北边一个坟。中间一个可怜的人。 仿佛被剪了线风筝,似是而非的放飞,却从此没了维系的根。 我妻姓吴。
1 下一页