小编puz*_*e87的帖子

复制表格并获得结果表格对象?

有没有简单/简短的方法来获取复制工作表时获得的新工作表的Excel.worksheet对象?

ActiveWorkbook.Sheets("Sheet1").Copy after:=someSheet
Run Code Online (Sandbox Code Playgroud)

事实证明,.Copy方法返回布尔值而不是工作表对象.否则,我本可以做到:

set newSheet = ActiveWorkbook.Sheets("Sheet1").Copy after:=someSheet    <-- doesn't work
Run Code Online (Sandbox Code Playgroud)

所以,我写了大约25行代码来获取对象(在复制之前列出所有工作表,列出所有工作表之后,并确定哪一个只在最后一个列表中.所有在VBA中非常冗长),但我正在寻找更优雅,更短的解决方案.

excel vba copy-paste worksheet excel-vba

28
推荐指数
4
解决办法
3万
查看次数

Main的入口点错误(字符串args)?

使用系统; 使用System.Collections.Generic; 使用System.Text;

namespace MyConApp
{
    class Program
    {
        static void Main(string args) 
        {
            string tmpString; 
            tmpString = args;
            Console.WriteLine("Hello" + tmpString);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

为什么下面的表达式显示编译错误消息"不包含适用于入口点的静态'Main'方法"

namespace MyConApp
{
    class Program
    {
        static void Main(string args) 
        {
            string tmpString; 
            tmpString = args;
            Console.WriteLine("Hello" + tmpString);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

谢谢.

c# syntax

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

当使用宏打开受信任的文档或启用宏时,Excel崩溃

如标题所述,我无法使用宏打开受信任的文档-Excel立即崩溃。制作文档的副本可以打开它(因为该副本不受信任),我可以在VB编辑器中检查宏,但是启用宏会导致另一次崩溃。为什么会发生这种情况,我该怎么解决?

excel vba excel-vba

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

数组 CountIf 替换 - Count(Match())

核心问题

如何CountIf()尽可能有效地(性能方面)在一个范围内执行重复的s?


关注细节

数组范围

Since each read/write to a spreadsheet results in slower VBA code, it is advisable to do so as few times as possible. Normally, if someone is repeatedly reading/writing to a range, he or she should first save that range to an array, perform the operations to the array, and then do a final read or write to the spreadsheet if necessary.


Example Values and Code

示例值

How can I use perform CountIf()s on the …

arrays excel vba countif

4
推荐指数
1
解决办法
9461
查看次数

不区分大小写的字符串比较

如果这两个字符串相等但不查看大写或小写,我正在尝试找到一种显示 MsgBox 的方法。

For teller = 1 To 51
If Cells(teller, 5).Value = Me.txtGebruikersnaam Then
    MsgBox ("Deze Gebruiker bestaat al!")
    Exit Sub
    Else
End If
Next
Run Code Online (Sandbox Code Playgroud)

我尝试使用:

If (StrComp(Cells(teller, 5).Value = Me.txtGebruikersnaam, vbTextCompare) = 0) Then
Run Code Online (Sandbox Code Playgroud)

但它没有用。

excel vba

0
推荐指数
1
解决办法
1087
查看次数

标签 统计

excel ×4

vba ×4

excel-vba ×2

arrays ×1

c# ×1

copy-paste ×1

countif ×1

syntax ×1

worksheet ×1