Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 清除范围内的单元格_Excel_Vba - Fatal编程技术网

Excel 清除范围内的单元格

Excel 清除范围内的单元格,excel,vba,Excel,Vba,我在使用我在功能区中创建的自定义按钮清除某个范围内的内容时遇到问题。该按钮工作正常,调用函数,但只有单元格“A6”清除,没有其他内容。我已经搜索了又搜索,并尝试了多次其他变化,每次都有相同的结果。这里只是一些尝试 Function ClearSheet() Worksheets("Template").Range("A6, I100000").ClearContents End Function Function ClearSheet() Worksheets("Tem

我在使用我在功能区中创建的自定义按钮清除某个范围内的内容时遇到问题。该按钮工作正常,调用函数,但只有单元格“A6”清除,没有其他内容。我已经搜索了又搜索,并尝试了多次其他变化,每次都有相同的结果。这里只是一些尝试

Function ClearSheet()

    Worksheets("Template").Range("A6, I100000").ClearContents

End Function


Function ClearSheet()

    Worksheets("Template").Range("A6, I100000").Clear

End Function

Function ClearSheet()

   With Worksheets("Template")
        .Range("A6, I100000").ClearContents
   End With

End Function

Function ClearSheet()
Dim Rng as Range
Rng  = Worksheets("Template").Range("A6, I100000")

    Rng.ClearContents

End Function

Function ClearSheet()

    Worksheets("Template").Range("A6, I100000").Value = ""

End Function

还有一百个人,我还缺什么请帮帮我

因为范围的正确用法是:


范围(“A6:I100000”)。ClearContent

因为范围的正确用法是:


Range(“A6:I100000”).ClearContent
Rng=工作表(“模板”).Range(“A6,I100000”)
需要是
Set Rng=工作表(“模板”).Range(“A6:I100000”)
——尽管如果只在一行代码中使用,设置范围变量几乎没有意义。
Rng=工作表(“模板”).Range(“A6,I100000”)
将需要
设置Rng=工作表(“模板”).Range(“A6:I100000”)
——虽然设置范围变量没有什么意义,如果你只在一行代码中使用它。哈哈,我已经把头发扯了几个小时了,我想我们都有金发的时刻,谢谢。哈哈,我已经扯掉头发好几个小时了,我想我们都有金发的时刻,谢谢。