|
▼Juri さん:
要件を誤解しているかもしれませんが・・・
Sub sample()
Dim rng As Range, myCell1 As Range, myCell2 As Range
Dim myStr As String
With Sheets("Sheet1")
Set rng = .Range("A1:IV" & .UsedRange.Cells(.UsedRange.Cells.Count).Row)
End With
myStr = "激動波"
Set myCell1 = getAddr(rng, myStr)
If Not myCell1 Is Nothing Then
myStr = "単価"
Set myCell2 = getAddr(rng, myStr)
If Not myCell2 Is Nothing Then
myCell1.EntireColumn.Copy
myCell2.Offset(, 1).EntireColumn.Insert shift:=xlToRight
Application.CutCopyMode = False
End If
End If
Set rng = Nothing
Set myCell1 = Nothing
Set myCell2 = Nothing
End Sub
Private Function getAddr(rng As Range, myStr As String) As Range
Set getAddr = rng.Find(What:=myStr, LookIn:=xlFormulas, LookAt _
:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, MatchByte:=False, SearchFormat:=False)
If getAddr Is Nothing Then MsgBox "領域内に" & myStr & "はありません"
End Function
|
|