展开全部
根据字符串特点和截取要求
一般可以用left,right,mid函数结合len、find等截取需要的字符串
一般可以用left,right,mid函数结合len、find等截取需要的字符串
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2015-06-15 · 知道合伙人软件行家
关注
展开全部
使用mid函数。
在VBA中使用方法如下:
application.worksheetfunction.mid()
在VBA中使用方法如下:
application.worksheetfunction.mid()
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
请试试,复制以下到代码工作表:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) '
If ActiveCell.Row <> 1 Then Exit Sub
Call aaa
End Sub
Sub aaa()
Dim j As Long, i As Long, r As Integer, id1 As Integer, id2 As Integer, arr
j = [A65536].End(xlUp).Row
arr = Range("A2:C" & j)
For i = 1 To UBound(arr)
If arr(i, 1) <> "" Then
id1 = WorksheetFunction.Find("色", arr(i, 1))
For r = id1 To 1 Step -1
If Mid(arr(i, 1), r, 1) = " " Then
arr(i, 2) = Mid(arr(i, 1), r + 1, id1 - r)
Exit For
End If
Next
id2 = WorksheetFunction.Find(":", arr(i, 1))
For r = 1 To Len(arr(i, 1))
If Mid(arr(i, 1), r, 1) = "档" Then
arr(i, 3) = Mid(arr(i, 1), id2 + 1, r - id2)
Exit For
End If
Next
Range("A2:C" & j) = arr
End If
Next
End Sub
双击第一行运行,希望帮到你
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) '
If ActiveCell.Row <> 1 Then Exit Sub
Call aaa
End Sub
Sub aaa()
Dim j As Long, i As Long, r As Integer, id1 As Integer, id2 As Integer, arr
j = [A65536].End(xlUp).Row
arr = Range("A2:C" & j)
For i = 1 To UBound(arr)
If arr(i, 1) <> "" Then
id1 = WorksheetFunction.Find("色", arr(i, 1))
For r = id1 To 1 Step -1
If Mid(arr(i, 1), r, 1) = " " Then
arr(i, 2) = Mid(arr(i, 1), r + 1, id1 - r)
Exit For
End If
Next
id2 = WorksheetFunction.Find(":", arr(i, 1))
For r = 1 To Len(arr(i, 1))
If Mid(arr(i, 1), r, 1) = "档" Then
arr(i, 3) = Mid(arr(i, 1), id2 + 1, r - id2)
Exit For
End If
Next
Range("A2:C" & j) = arr
End If
Next
End Sub
双击第一行运行,希望帮到你
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Sub qgrmdtj()
myPath = "C:\Users\sfx004\Desktop\Test" '把文件路径定义给变量
n = 2
myFile = Dir(myPath & "\*.*")
Do While myFile <> ""
Cells(n, 1) = myFile
myFile = Dir '找寻下 文件
n = n + 1
Loop
End Sub
myPath = "C:\Users\sfx004\Desktop\Test" '把文件路径定义给变量
n = 2
myFile = Dir(myPath & "\*.*")
Do While myFile <> ""
Cells(n, 1) = myFile
myFile = Dir '找寻下 文件
n = n + 1
Loop
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询