>>974 ざんねんながら同じ行です。 I'm afraid both of the tables are overrapping each other. >>975 そんな簡単にできるんだ。実際できたよ! I never dreamed that it can be handled that easily. I did it!
>>985 Sub hoge() Dim v As String Dim i As Long Dim myStr As String Dim NStr As String Dim Bln As Boolean v = ActiveCell.End(xlUp).Value If v = "" Then Exit Sub Bln = False For i = Len(v) To 1 Step -1 myStr = Mid(v, i, 1) If myStr Like "[0-9]" Then Bln = True NStr = myStr & NStr ElseIf Bln = True Then Exit For End If Next i If IsNumeric(NStr) Then NStr = NStr + 1 NStr = Left(v, i) & NStr ActiveCell.Value = NStr End Sub 末尾の半角整数が+1になる。数字がなければそのままコピー。 ツール→マクロ→オプション でショートカットキーを設定できる。
Function 謎処理() '半角数字の含まれるセルを上向きにサーチ Dim str1 As String Dim R As Integer, C As Integer Dim F As Boolean Dim L As Integer
R = Application.Caller.Row C = Application.Caller.Column
F = True While R > 1 And F R = R - 1 str1 = Cells(R, C).Text L = Len(str1) While L > 0 And F If "0" <= Mid(str1, L, 1) And Mid(str1, L, 1) <= "9" Then F = False L = L - 1 Wend Wend
If F Then 謎処理 = CVErr(xlErrValue) Else 謎処理 = 謎2(str1) End If End Function
Function 謎2(str1) '数値を置き換える Dim str2 As String Dim ch As String Dim F As Boolean Dim n As Variant str2 = ""
F = True While Len(str1) > 0 And F ch = Left(str1, 1) If "0" <= ch And ch <= "9" Then n = Int(Val(str1)) str1 = Mid(str1, Len(n) + 1): str2 = str2 & (n + 1) F = False Else str1 = Mid(str1, 2): str2 = str2 & ch End If Wend
While Len(str1) > 0 ch = Left(str1, 1) If "0" <= ch And ch <= "9" Then n = Int(Val(str1)) str1 = Mid(str1, Len(n) + 1): str2 = str2 & "1" Else str1 = Mid(str1, 2): str2 = str2 & ch End If Wend 謎2 = str2 End Function