写一个excel的vba逻辑是检查H列的数据删除H列单元格中的首个英文字符
Sub DeleteFirstLetter() Dim lastRow As Long Dim i As Long Dim cellValue As String Dim firstLetter As String
lastRow = ActiveSheet.Cells(Rows.Count, 8).End(xlUp).Row '获取H列的最后一行行号
For i = 1 To lastRow '循环遍历每行数据
cellValue = Range("H" & i).Value '获取当前单元格的值
firstLetter = Left(cellValue, 1) '获取第一个字符
If IsLetter(firstLetter) Then '判断第一个字符是否为英文字母
Range("H" & i).Value = Right(cellValue, Len(cellValue) - 1) '删除第一个字符
End If
Next i
End Sub
Function IsLetter(str As String) As Boolean '判断是否为英文字母 If str Like "[a-zA-Z]" Then IsLetter = True Else IsLetter = False End If End Function
原文地址: https://www.cveoy.top/t/topic/biGR 著作权归作者所有。请勿转载和采集!