|
以下自分で書いてみたものです。
原因はrange型の変数とstring型の変数を=で結んだからかな?と予想していますが、どう書き換えたらいいのかわかりません。ご教授お願いします…
Sub test()
Application.ScreenUpdating = False
Dim sh1 As Object
Dim pos1 As Range
Dim pos1row As Long
Dim pos1col As Long
Dim name1 As String
Dim name2 As String
Dim name3 As String
Dim name4 As String
Dim name5 As String
Dim name6 As String
Dim name7 As String
Dim name8 As String
Dim name9 As String
Dim memo As Range
Set sh1 = Sheets("sheet1")
pos1col = 8
pos1row = 5
Set pos1 = Cells(pos1row, pos1col).MergeArea
Set memo = pos1.Offset(, 7)
Do While Not IsEmpty(pos1)
name1 = "a"
name2 = "b"
name3 = "c"
name4 = "d"
name5 = "e"
name6 = "f"
name7 = "g"
name8 = "h"
name9 = "i"
Select Case pos1.Value
Case Is = name1
memo = "aa"
Case Is = name2
memo = "bb1" & Right(pos1.Offset(, 3).Value, 5) & "bb2" _
& Left(pos1.Offset(, 3).Value, 4) & "bb3"
Case Is = name3
memo = bb1" & Right(pos1.Offset(, 3).Value, 5) & "bb2" _
& Left(pos1.Offset(, 3).Value, 4) & "bb3"
Case Is = name4
memo = pos1.Offset(, 3).Value & "dd"
Case Is = name5
memo = "ee"
Case Is = name6
memo = "ff"
Case Is = name7
memo = pos1.Offset(, 3).Value & "gg"
Case Is = name8
memo = "hh"
Case Is = name9
memo = pos1.Offset(, 3).Value & "ii"
End Select
pos1row = pos1row + 1
Set pos1 = sh1.Cells(pos1row, pos1col).MergeArea
Loop
End Sub
|
|