当我激活工作表时,我希望excel执行以下过程:
单元格“A1和单元格”Z1“是否在我的屏幕范围内?
是: 什么都不做
否:
Range("A1:Z1").Select
ActiveWindow.Zoom = True
我想要这个,因为我的文件必须在不同的屏幕/屏幕分辨率下打开,所有人都必须看到所有内容。
我希望有人可以帮助我。
答案 0 :(得分:0)
从我在评论中发布的链接中,我想出了这段代码
Sub temp()
Dim zoomRatio As Integer
zoomRatio = 100
Do While (Not (CellIsInVisibleRange(ActiveSheet.Range("Z1"))))
zoomRatio = zoomRatio - 1
ActiveWindow.Zoom = zoomRatio
Loop
End Sub
Function CellIsInVisibleRange(cell As Range)
CellIsInVisibleRange = Not Intersect(ActiveWindow.VisibleRange, cell) Is Nothing
End Function
<强>更新强>
修改子程序以放大,如果超过Z列可见,如果小于Col Z可见,则缩小
Sub temp()
Dim zoomRatio As Integer
zoomRatio = ActiveWindow.Zoom
Do While (Not (CellIsInVisibleRange(ActiveSheet.Range("Z1"))))
zoomRatio = zoomRatio - 2
ActiveWindow.Zoom = zoomRatio
Loop
Do While (CellIsInVisibleRange(ActiveSheet.Range("AA1")))
zoomRatio = zoomRatio + 2
ActiveWindow.Zoom = zoomRatio
Loop
End Sub
答案 1 :(得分:0)
我修好了。谢谢!
Private Sub Worksheet_Activate()
If CellIsInVisibleRange(ActiveSheet.Range("Z2")) Then
'Nothing
Else
Range("A2:Z2").Select
ActiveWindow.Zoom = True
Range("D3").Select
End If
End Sub
Function CellIsInVisibleRange(cell As Range)
CellIsInVisibleRange = Not Intersect(ActiveWindow.VisibleRange, cell) Is Nothing
End Function
答案 2 :(得分:0)
难道你不能检查范围是否已经适合以及它是否没有调用缩放方法?
[[UITabBar appearance] setBackgroundImage:[[UIImage alloc] init]];
[[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];