Question

I am trying to, Merge the visible cells such that the first sheet acts as introduction page with just once cell and has the text centered. So by visible, I mean the cells visible on the users screen. So if my monitor has a different size/resolution then the visible cells are different in number/range.

How do I get range of the visible cells?

Here is what i have tried.

  visibleCells = myRange.SpecialCells(Excel.XlCellType.xlCellTypeVisible);

I have tried different variations for myRange, but i am unable to get the range of the cells that are on the visible part of the screen.

Was it helpful?

Solution

How about:

Sub dural()
    Dim w As Window, r As Range
    Set w = ActiveWindow
    Set r = w.VisibleRange
    r.MergeCells = True
    r.HorizontalAlignment = xlCenter
    r.VerticalAlignment = xlCenter
    r.Value = "Hello World"
End Sub
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top