名前を含む多数のセルを含むスプレッドシートを定期的に受け取っています。一部のセルには、ピリオド付きのミドル ネームを含む完全な名前があります。
例えば:
スプリンガー、ジェリー A.
ときどき受け取るシートには次のようなものがあります。
スプリンガー、ジェリー。
これらのミドルネームのイニシャルを削除する必要がありますが、「.」だけを削除したことを確認する必要もあります。そこにあれば。
適切なロジックが不足していることをお許しください。ただし、次の ca-ca サブがあります。
Sub DeleteMiddleI()
Dim nr1, nr2 As Range
Dim col As Integer
col = 1
Set nr1 = Cells(65536, col).End(xlUp)
Set nr2 = Cells(col, 1)
Do While nr2 <> nr1
'Check to be sure the cell isn't empty
If Len(nr2) <> 0 Then
'Check to see if the last character is a "."
If Right$(nr2, 1) = "." Then
'Check and be sure there is a character before the "."
If InStr(1, nr2.Text, "[A-Z].") > 0 Then '<<<<<<CODE BREAKAGE
nr2 = Left$(nr2, Len(nr2) - 3)
End If
End If
End If
col = col + 1
Set nr2 = Cells(col, 1)
Loop
End Sub
それは上で壊れます
InStr(1, nr2.Text, "[AZ].") > 0 の場合
私はばかだと感じます...しかし、何が欠けていますか?