0
尝试在VBA for Excel中编写宏以查看列表中每行数据的某个列中的值,并且如果该值为“是”,那么它将整行复制并粘贴到同一工作簿中的不同工作表上。我们来命名两张表“数据”和“最终”。我想要引用工作表,因此在运行代码时打开哪张工作表并不重要。我打算使用Do
循环来循环查看一个数据表中的行,直到找到没有更多的条目和if语句来检查这些值。使用VBA代码在工作簿中的工作表中复制和粘贴
我对如何从一张纸切换到下一张感到困惑。
如何特别参考不同工作表中的单元格?
这里是伪代码我脑子里想的:
Do while DataCells(x,1).Value <> " "
for each DataCells(x,1).Value="NO"
if DataCells(x,2).Value > DataCells(x,3).Value or _
DataCells(x,4).Value < DataCells(x,5).Value
'Copy and paste/insert row x from Data to Final sheet adding a new
'row for each qualifying row
else
x=x+1
end
else if DataCells(x,1).Value="YES"
Loop
'copy and paste entire row to a third sheet
'continue this cycle until all rows in the data sheet are examined
你需要更清楚地格式化代码;就像现在这样,由于缺少行或缩进,代码不可读。 – LittleBobbyTables
请使用搜索功能。 – user2140261