网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
07月20日漏签0天
excel吧 关注:281,356贴子:1,549,807
  • 看贴

  • 图片

  • 吧主推荐

  • 视频

  • 游戏

  • 17回复贴,共1页
<<返回excel吧
>0< 加载中...

求助!求解释!求改写!

  • 只看楼主
  • 收藏

  • 回复
  • 可神可神经
  • 见E勇为
    7
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
' 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


  • 可神可神经
  • 见E勇为
    7
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
' 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


2025-07-20 01:08:25
广告
  • 可神可神经
  • 见E勇为
    7
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
这是从网络上找的一段代码


  • 可神可神经
  • 见E勇为
    7
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
我的基本诉求是:
单元格内插入换行符,自动换行后,对换行后的数据进行自动编码序号.
应该描述清楚了.


  • 可神可神经
  • 见E勇为
    7
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
那段代码应该是很早起的自定义函数应用.


  • 可神可神经
  • 见E勇为
    7
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
我看不懂,
麻烦路过的大神指导一下.
帮忙解释一下
帮忙删改无用信息,保留完整有用信息.
连接符"-"或"+"


  • 菠萝蜜
  • E览无余
    11
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
Option Explicit
' 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


  • 可神可神经
  • 见E勇为
    7
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼




2025-07-20 01:02:25
广告
  • 菠萝蜜
  • E览无余
    11
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼


Option Explicit
Sub abc()
 Dim r As Range, i, j, t
 For Each r In ActiveSheet.UsedRange
  If Len(r.Value) Then
   If Left(r.Value, 2) <> "1." Then
    t = Split(Replace(r.Value, vbLf, "+"), "+")
    For j = 0 To UBound(t)
     t(j) = j + 1 & "." & t(j)
    Next
    r = Join(t, vbLf)
   End If
  End If
 Next
End Sub


  • 菠萝蜜
  • E览无余
    11
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
'加了几个限定条件
Option Explicit
Sub abc()
 Dim r As Range, i, j, t, n
 For Each r In ActiveSheet.UsedRange
  If Len(r.Value) Then
   If Left(r.Value, 2) <> "1." Then
    t = Replace(r.Value, vbLf, "+")
    If InStr(t, "+") Then
     t = Split(t, "+"): n = 0
     For j = 0 To UBound(t)
      If Len(t(j)) Then t(j) = j + 1 & "." & t(j): n = n + 1
     Next
     If n > 1 Then ReDim Preserve t(n - 1): r = Join(t, vbLf)
    End If
   End If
  End If
 Next
End Sub


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 17回复贴,共1页
<<返回excel吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示