サブの最初の部分(ヘッダーリストの列に作用する)を他の種類のアクションに適用する方法を見つけようとしています(オリジナルはリストの列を削除するように設定されていました)。
私の試みは、リストにいくつかの単純なフォーマットを適用するという点でほとんどうまくいきます:「RespID、Score」
ただし、サブはリスト「RespID」の最初の項目にのみ適用されます
サブで変更したのは、'~~> Act on columns
ありがとう
Sub FormatRespIDScore360()
Dim WS As Worksheet
Dim ColList As String, ColArray() As String
Dim lastCol As Long, i As Long, j As Long
Dim boolFound As Boolean
Dim delCols As Range
Dim lastRow As Long
On Error GoTo Whoa
Application.ScreenUpdating = False
Set WS = Sheets("360")
ColList = "RespID, Score"
ColArray = Split(ColList, ",")
'~~> Get the last column
lastCol = WS.Cells.Find(What:=" ", After:=WS.Range("A1"), LookAt:=xlPart, _
LookIn:=xlFormulas, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, _
MatchCase:=False).Column
For i = 1 To lastCol
boolFound = False
'~~> Checking of the current cell value is present in the array
For j = LBound(ColArray) To UBound(ColArray)
If UCase(Trim(WS.Cells(1, i).Value)) = UCase(Trim(ColArray(j))) Then
'~~> Match Found
boolFound = True
Exit For
End If
Next
'~~> If not match not found
If boolFound = True Then
If delCols Is Nothing Then
Set delCols = WS.Columns(i)
Else
Set delCols = Union(delCols, WS.Columns(i))
End If
End If
Next i
'~~> Act on columns
If Not delCols Is Nothing Then
With Sheets(1)
lastRow = .Cells(.Rows.Count, delCols.Column).End(xlUp).Row
End With
With Sheets(1).Range(delCols, WS.Cells(lastRow, delCols.Column))
.NumberFormat = "0"
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End If
LetsContinue:
Application.ScreenUpdating = True
Exit Sub
Whoa:
MsgBox Err.Description
Resume LetsContinue
End Sub