我编写了代码来为工作表列执行唯一的记录过滤器,并将每个列(在过滤器之后)复制到新的工作表中。当前代码如下所示:
sub Test()
Worksheets.Add(After:=Worksheets(3)).Name = "Unique Filter"
For i = 1 To 12
Sheets("Sheet3").Columns(i).Copy Sheets("Unique Filter").Columns(i)
Next
Worksheets("Unique Filter").Activate
For i = 1 To 12
Columns(i).AdvancedFilter Action:=xlFilterInPlace, Unique:=True
Next
End sub
它会在当前工作表之后创建一个新工作表(这是我工作簿中的工作表编号3)。
宏给我留下了新的Excel“独特过滤器”,如下所示:看起来并不正确:(在表3的原始10K行中应该有大约600条唯一记录,而不是1)
答案 0 :(得分:0)
您可能希望跳过初始复制粘贴,而是使用高级过滤器的复制粘贴功能。如果我没有隐藏的行等,我总会得到意想不到的结果。可能都是可以解释的,但我从未调查过,发现这是一个更快的解决方案。
所以 - 稍微修改你的代码......
#include <iostream>
#include <ctype.h>
int main()
{
float a, b;
char again = 'Y';
std::cout << "After several hours on the road you wonder what your gas mileage must have been..." << "\n";
while (again == 'y' || again == 'Y')
{
std::cout << "How much gas did you have in your tank to start with?" << "\n";
while (!(std::cin >> a))//cin for float a
{
std::cout << "Your input must be a number...1" << "\n";
std::cin.clear();
std::cin.ignore(1000000, '\n');
}
if (a > 0)
std::cout << "How many miles did you travel?" << "\n";
while (!(std::cin >> b))//cin for float b
{
std::cout << "Your input must be a number...2" << "\n";
std::cin.clear();
std::cin.ignore(1000000, '\n');
}
if (b > 0)
std::cout << "You have obtained an whopping " << b / a << " miles to the gallon!" << "\n" << "\n";
std::cout << "Would you like to try again? (Y/N): ";
std::cin >> again;
}
}