当前位置:首页经验技巧Excel经验excel财务

excel怎么插入带公式的页眉

2024-07-26 11:08:34

1.excel页眉页脚中怎样插入公式?

利用分节符可以实现不同页眉的显示。可以用一个宏来自动完成。

Sub test()

Dim pageNum As Long

Dim sectionNum As Long

Selection.HomeKey unit:=wdStory

With Selection.Find

.ClearFormatting

.Execute findText:="^b", ReplaceWith:="", Replace:=wdReplaceAll, Format:=False, Forward:=True, Wrap:=wdFindContinue

End With

ActiveDocument.Repaginate

pageNum = ActiveDocument.(wdPropertyPages)

sectionNum = 0

For i = 1 To pageNum

If i Mod 3 = 0 Then

Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:=(i + 1)

Selection.MoveUp unit:=wdLine, Count:=1

Selection.EndKey unit:=wdLine

Selection.InsertBreak Type:= '

sectionNum = sectionNum + 1

End If

Next i

If ActiveWindow.View.SplitSpecial <> wdPaneNone Then

ActiveWindow.Panes(2).Close

End If

If ActiveWindow.ActivePane.View.Type = wdNormalView _

Or ActiveWindow.ActivePane.View.Type = wdOutlineView Then

ActiveWindow.ActivePane.View.Type = wdPrintView

End If

For i = 1 To (sectionNum + 1)

Selection.GoTo What:=wdGoToSection, Which:=wdGoToFirst, Count:=i

Selection.MoveDown unit:=wdScreen, Count:=1

ActiveWindow.ActivePane.View.SeekView =

If i >= 2 Then

Selection.HeaderFooter.LinkToPrevious = False

End If

Selection.HeaderFooter.Range.Delete

Selection.TypeText Text:="第" & i &; "批次体检人员名单"

ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

Next i

Selection.HomeKey unit:=wdStory

End Sub

---------------------------------------

啊,我看错了,以为是Word里面的呢!白写了,呵呵。


电脑版

免责声明:本站信息来自网络收集及网友投稿,仅供参考,如果有错误请反馈给我们更正,对文中内容的真实性和完整性本站不提供任何保证,不承但任何责任,谢谢您的合作。
版权所有:五学知识网 Copyright © 2015-2024 All Rights Reserved .