|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub Test()
- Dim arrTitle As Variant
- Dim arr As Variant, lngRow As Long, lngR As Long
- Dim brr As Variant, arrResult As Variant
- Dim strTemp As String
-
-
- arr = Sheet1.Range("B2:AF26")
- arrTitle = Application.WorksheetFunction.Index(arr, 1, 0)
- arrResult = Sheet1.Range("AG2:AG26")
-
- For lngRow = 2 To UBound(arr)
- brr = Application.WorksheetFunction.Index(arr, lngRow, 0)
- For lngR = LBound(brr) To UBound(brr)
- If brr(lngR) <> "" Then brr(lngR) = arrTitle(lngR)
- Next
- strTemp = Join(brr, " ")
- strTemp = Trim(strTemp)
- strTemp = Replace(strTemp, " ", "-")
- strTemp = Replace(strTemp, "--", "/")
- Do Until InStr(strTemp, "//") < 1
- strTemp = Replace(strTemp, "//", "/")
- Loop
- strTemp = Replace(strTemp, "/-", "/")
- arrResult(lngRow, 1) = strTemp
- Next
-
- Sheet1.Range("AG2:AG26") = arrResult
- End Sub
复制代码 |
|