私はvbaの新人です。比較的簡単なものについています: 私はヘッダー名から列番号を指定しています:データをソートするためのダイナミックレンジ(列)をコーディングするVBA
Dim onomata As Integer
'find column named Name of ship
Set acell = rows(1).Find(What:="Name of ship", LookIn:=xlValues, _
LookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
If Not acell Is Nothing Then
onomata = acell.Column
End If
今、私はこのコラムに基づいて自分のデータをソートする:コマンドが範囲値を要求しながら
Cells.Select
ActiveWorkbook.ActiveSheet.Sort.SortFields.Clear
ActiveWorkbook.ActiveSheet.Sort.SortFields.Add Key:=Range(*this is where I want to introduce the column*), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With ActiveWorkbook.ActiveSheet.Sort
.SetRange Range("A1:AR100000")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
はしかし、私の変数は整数です。それをコード化する方法を教えてもらえますか?
あなたはこれだけを必要とする
多くのありがとう!それは完全に動作します! –
@ e-gnacioあなたは大丈夫です –
2つ以上の基準で並べ替えたい場合はどうすればよいですか?最初の並べ替えは列Aで、次に列Bで並べ替えるのが好きですか? –