在判断单元格是否为空时,可以结合使用 Range 对象和 IsEmpty 函数。 vba Sub CheckCellIsEmpty1() Dim ws As Worksheet Set ws = ThisWorkbook.Sheets("Sheet1") ' 假设工作表名为Sheet1 Dim cell As Range Set cell = ws.Range("A1") ' 要检查的单元格 If IsEmpty(cell.Value) Then MsgBox "单元格...
Sub run()On Error GoTo 999 Sheets("sheet1").Select Exit Sub 999 Sheets.Add ActiveSheet.Name = "sheet1"End Sub
If ActiveSheet.Name = "清单" Then Exit sub
其实,看左侧窗口都可以发现问题出在哪里了,你代码所在工作簿中没有"Sheet1"这张工作表 所以,代码可以更正为:工作表1.select 或者: worksheets("工作表1").select 抑或:worksheets(1).select
如果定义的sh数据类型为worksheet,tempBook.后面应该是Worksheets吧 Sheets可能包含图表工作表,仅供参考
都为空了,哪里有返回值?set rng=sheet2.range("F5:F10")n=0 for each cl in rng if cl<>"" then n=n+1 next if n=0 then msgbox "区域为空"
SheetIsBlank = rng Is Nothing End Function I expect you would need to complete the missing arguments in the Find function Peter Thornton Tuesday, May 31, 2011 11:32 AM the is no easy wasy of telling if a worksheet is empty without check each cell for data which may take a lot of ...
语法上的问题,应该是 Sheets(1).Select
End If Next IsSheetExisted = False End Function 我们将函数名随便起了个名字叫IsSheetExisted,函数只有一个字符串型参数tabname代表以后要传入的工作表标签名称,函数返回Boolean类型结果(True/False)。下面,我们就可以在其它VBA程序中使用该函数了,见下面代码: ...
b = 1 For a = 1 To Workbooks("1.xls").Worksheets("Sheet1").[A65536].End(xlUp).Row If Workbooks("1.xls").Worksheets("Sheet1").Range("b" & a).Value = "" Then Workbooks("1.xls").Worksheets("Sheet1").Range("a" & a).Copy Workbooks("2.xls").Worksheets("Sheet1...