'E9'セルをフィルタリングした後、 'D'、 'F'、および 'G'セルの値をコピーしたいと思います。しかし、私はそれらをコピーすると、隠されたセルも同様にコピーされます。私はフィルタリングされたセルをコピーし、隠されたセルはコピーしません。それ以外は、コードをハードコピーする代わりにループにして、次のフィルタリングされたセルを検索できるようにすることができます。セル 'D'のすべてをコピーするのではなく、 'D31'、 'D68'、 'D105'などをコピーしたいだけです。私はまだあなたの援助のいくつかを持っていたいと思いますので、私はまだマクロに新しいので、それをコーディングする方法はありますか、ありがとう。フィルタリングされたセルをコピーすることは可能ですか?
Sub trial()
Dim wb As Workbook, wb2 As Workbook, wb3 As Workbook
Dim fn As String
Set wb = ActiveWorkbook
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
If .Show = -1 Then
fn = .SelectedItems(1)
Set wb2 = Workbooks.Open(fn)
Else
MsgBox "You cancel the process."
Exit Sub
End If
End With
Dim ws As Worksheet
wb2.Activate
Application.DecimalSeparator = ","
Application.ThousandsSeparator = "."
Application.UseSystemSeparators = True
Sheets(1).AutoFilterMode = False
Sheets(1).Range("$A$9:$P$417").AutoFilter Field:=5, Criteria1:= _
"1,000,000"
Range("F31:F804").Select
Selection.Copy
wb.Activate
'determine the sheet you want to copy to and search for the next empty row
'change the commas to dot as well
Sheets(2).Activate
Dim FirstCell As String
Dim i As Integer
FirstCell = "D19"
Range(FirstCell).Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value = "" Then
Exit Do
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
wb2.Activate
Range("D31:D804").Select
Application.CutCopyMode = False
Selection.Copy
wb.Activate
'determine the sheet you want to copy to and search for the next empty row
Sheets(3).Activate
FirstCell = "D19"
Range(FirstCell).Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value = "" Then
Exit Do
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
wb2.Activate
Range("G31:G804").Select
Application.CutCopyMode = False
Selection.Copy
wb.Activate
'determine the sheet you want to copy to and search for the next empty row
Sheets(4).Activate
FirstCell = "D19"
Range(FirstCell).Select
Do Until ActiveCell.Value = ""
If ActiveCell.Value = "" Then
Exit Do
Else
ActiveCell.Offset(1, 0).Select
End If
Loop
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
wb2.Close
End Sub
This is the link to the image for your reference
申し訳ありませんが、私はこの記事の前半で言及していませんでした。私は手動ではなくマクロでもそれをやりたいと思っています。 – Fong
Spはセル 'D31'から始まり、 ?どこに細胞をコピーしていますか?目的地は何ですか? – dwirony
はい、これはこのワークシートの37番目のセルです。しかし、ワークシートを切り替えると、それはもう同じではないかもしれません。ハードコーディングはそれほど難しくありません。たとえば、列をフィルタリングした後、excelはフィルタリングされたセル( 'D31'、 'D68'、 'D105'など)を別のブックに1つずつコピーします...使用範囲は使用できませんこの場合、隠れたセルもコピーされます。@dwirony – Fong