移動し続ける列があります。ヘッダー名を使用するようにいくつかのマクロを書き直そうとしています。コードをサブに適用する際に問題が発生しました。
Trying to replace this: Columns("EO:EO").Select
と
Columns("aCell:aCell").Select
他のさまざまな方法を試しましたが、何も機能しません。
ありがとう
Function LCol(ColumnNumber As Long) As String
Dim ColNum As Integer
Dim ColLetters As String
ColNum = ColumnNumber
ColLetters = ""
Do
ColLetters = Chr(((ColNum - 1) Mod 26) + 65) & ColLetters
ColNum = Int((ColNum - ((ColNum - 1) Mod 26)) / 26)
Loop While ColNum > 0
LCol = ColLetters
End Function
サブ
Sub RenameOther()
Dim strSearch As String
Dim aCell As Range
Dim colz As Range
strSearch = "attribute_4"
Set aCell = Sheet1.Rows(1).Find(What:=strSearch, LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not aCell Is Nothing Then
'Trying to replace this: Columns("EO:EO").Select
Columns("aCell:aCell").Select
Selection.Replace What:="Client/Customer/Other (optional)", Replacement:="Other", _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:= _
False, ReplaceFormat:=False
Cells(2, aCell.Column).Select
End If
End Sub