View Single Post
 
Old 10-11-2022, 01:48 PM
BobBridges's Avatar
BobBridges BobBridges is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

So you already have a VBA program that calculates the number of pages, and displays it using MsgBox, right? If you want your program to put that number in a cell of a worksheet, the code looks something like this:
Code:
set ows = ActiveSheet
npg = (ows.HPageBreaks.Count + 1) * (ows.VPageBreaks.Count + 1)
set ocs = ows.Cells
ocs(1, 1).Value = npg 'row 1, col 1
There are other ways to code it; this is the way I probably would.
Reply With Quote