小编kv.*_*pia的帖子

Excel VBA代码过滤两列并提取数据

这是我的第一篇文章,我对此感到非常兴奋。如果我的写作没有意义,我提前道歉,因为我不太熟悉编码/编程术语。

这是 我正在使用的Micro_Enabled_Excel_File 。

我有一个包含多列和行的 Excel 文件。行数会随着时间的推移而增加。我正在尝试过滤两列并复制最新/最新的数据点(行)并将其粘贴到新工作表中以创建状态报告。

Excel 数据集:图像

结果会是什么样子:图片

到目前为止我所做的:

  1. 创建了一个 Micro 来浏览“范围”和“贸易名称”列,以获取唯一条目并将其复制到另一个名为“代码”的表中。
Sub First_COPY_STYLE_TO_REPORT()

    'creating the Report sheet
    Sheets("Report").Select
    Cells.Select
    Selection.Delete Shift:=xlUp
    Sheets("Status Updates").Select
    Cells.Select
    Selection.Copy
    Sheets("Report").Select
    ActiveSheet.Paste
    Rows("2:1048576").Select
    Application.CutCopyMode = False
    Selection.ClearContents

End Sub
Run Code Online (Sandbox Code Playgroud)
  1. 创建了一个 Micro 来创建工作表“报告”的模板,该模板最终将填充下一个 Micro 的结果。
Sub Second_COPY_UNIQUE_TO_CODE()

'add title to filter columns in the Code sheet
    Sheets("Code").Select
    Rows("1:1").Select
    Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
    Range("A1").Select
    ActiveCell.FormulaR1C1 = "Filter1"
    Range("B1").Select
    ActiveCell.FormulaR1C1 = "Filter2"

'creating the filter criteria also known as scope and trade name …
Run Code Online (Sandbox Code Playgroud)

excel vba for-loop filtering

3
推荐指数
1
解决办法
1253
查看次数

标签 统计

excel ×1

filtering ×1

for-loop ×1

vba ×1