|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Function SSLJ(rgData As Range, Optional LineType As Variant = "", Optional DispLocation As Variant = "") As Variant
- Dim rgFormula As Range '公式所在区域
- Dim arrData As Variant, strResult() As String
- Dim lngRows As Long, lngCols As Long
- Dim lngR As Long, lngC As Long
- Dim strTemp As String, strLast As String
- Dim lngLen As Long, lngMod As Long
- Dim arrTemp As Variant, lngIndex As Long
- Dim lngLineType As Long, lngDispLocation As Long
-
-
-
- Set rgFormula = Application.Caller
- lngRows = rgFormula.Rows.Count
- lngCols = rgFormula.Columns.Count
- ReDim strResult(1 To lngRows, 1 To lngCols) As String
-
- If LineType = "" Then
- lngLineType = 0
- Else
- lngLineType = Val(LineType)
- End If
-
- If DispLocation = "" Then
- lngDispLocation = 0
- Else
- lngDispLocation = Val(DispLocation) - rgFormula.Row
- End If
-
-
- If rgData.Rows.Count < 3 Then Exit Function '如果不足3行,直接退出
-
- arrData = rgData
- arrData = Application.WorksheetFunction.Transpose(arrData)
- strTemp = Join(arrData, ""): strTemp = Replace(strTemp, Space(1), "")
- lngLen = Len(strTemp)
- strLast = Mid(strTemp, lngLen - 1): strTemp = Mid(strTemp, 1, lngLen - 2)
- lngLen = lngLen - 2: lngMod = lngLen Mod 3: lngLen = lngLen \ 3
- strTemp = Mid(strTemp, lngMod + 1)
-
- ReDim arrTemp(1 To lngLen)
- For lngMod = 1 To lngLen
- arrTemp(lngMod) = Mid(strTemp, 1 + (lngMod - 1) * 3, 3)
- Next
-
- lngDispLocation = lngDispLocation - lngLen + 1
- If lngDispLocation < 0 Then lngDispLocation = 0
-
- For lngIndex = 1 To lngLen
- strResult(lngIndex + lngDispLocation, 1) = arrTemp(lngIndex)
- Next
-
- If lngLineType <> 0 Then strResult(lngIndex + lngDispLocation, 1) = strLast
-
- SSLJ = strResult
- End Function
复制代码 |
评分
-
2
查看全部评分
-
|