从macros返回整数

我试图循环通过我的Excel电子表格中的特定行。 对于第一组即时尝试循环通过每3行,以查看是否隐藏和第二个循环我正在步进每2个。我基本上想要添加什么真正的通过两个循环,并返回该值。 “返回y”部分给我一个错误。

Function FindHiddenRows() As Integer Dim x As Integer Dim y As Integer y = 0 For x = 23 To 38 Step 3 If Rows("x:x").EntireRow.Hidden = False Then y = y + 1 End If Next x For x = 40 To 46 Step 2 If Rows("x:x").EntireRow.Hidden = False Then y = y + 1 End If Next x Return y End Function 

使其快速/简短/容易:

 Function FindHiddenRows() As Byte Dim x As Byte, y As Byte For x = 22 To 46 Step 2 If x < 38 Then x = x + 1 If Not Rows(x).Hidden Then y = y + 1 Next FindHiddenRows = y End Function