Hello,
I have been trying to figure out how to add borders to all the used pages, and not just the used cells or rows. I can easily detect the last used row by using something like this, but that’s not what I need:
LastRow = ActiveSheet.UsedRange.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
I am having problems automatically locating the last row of the last used page. It is possible to locate each page break from something like this:
For Each pb In ActiveSheet.HPageBreaks
LastRow = pb.Location.Offset(-1, 0).row
Next pb
The problem is that I can’t find the last row from this, since there is no page break at that position. For example if there is only one page, there are no page breaks, but I still want to obtain the last row number. At the moment I have defined the last row number by assuming that the number of rows on each page always is the same and a predefined number, but I want it to be more flexible.
Can anyone help me with this?
Thanks in advance,
/Kristine
Bookmarks