kissingthefire

功能:v列有值的单元格内字符串截取

 1 Sub Demo3()
 2 Dim str
 3     With ActiveSheet
 4          For i = 2 To .Range("v65535").End(xlUp).Row
 5              If Not Len(Trim(ActiveSheet.Cells(i, 22))) = 0 Then
 6                  str = ActiveSheet.Cells(i, 22)
 7                  ActiveSheet.Cells(i, 22 - 6) = Left(str, InStr(str, "///") - 1)
 8                  ActiveSheet.Cells(i, 22 - 4) = Right(str, Len(str) - InStrRev(str, "/"))
 9                  ActiveSheet.Cells(i, 22 - 5) = Mid(str, InStr(str, "///") + 3, InStrRev(str, "///") - (InStr(str, "///") + 3))
10              End If
11          Next
12     End With
13     MsgBox ("恭喜你完成任务!")
14 End Sub

讲一下:

Range("v65535").End(xlUp).Row

  获得Excel最下面一个有内容的单元格的行

Len(Trim(ActiveSheet.Cells(i, 22))) = 0

  判断单元格内是否是有值的,可以排除有空格的影响

分类:

技术点:

相关文章:

  • 2021-12-18
  • 2021-11-18
  • 2021-08-10
  • 2022-12-23
  • 2022-01-07
  • 2021-11-30
  • 2021-12-05
  • 2021-07-31
猜你喜欢
  • 2022-01-01
  • 2021-11-05
  • 2022-12-23
  • 2022-12-23
  • 2021-08-11
  • 2021-05-22
相关资源
相似解决方案