问题描述
我想将单元格引用到另一个工作表中,并将其放在中间标题中,并将其格式化为特定的字体和大小。
接下来,我想采用右侧标题,并将报告的名称作为顶部,并使用特定大小的粗体字体,而下面的线条具有单独的大小且不粗体。如下所示:
合规性报告(这不需要单元格引用,它可以保持不变)。 b
$ b
保单日期2014 | 2015年9月30日(这个帐户之间的变化,需要来自源范围。)
我从这段代码开始:
子标题()
使用Worksheets(Sheet1)。PageSetup
.RightHeader =工作表(合规性报告)。 (a99)_
& Chr(10)&工作表(合规性报告)。范围(a100)
结束于
结束小组
它用于获取两行数据,但我无法格式化它。如果有更好的选择,我不会拘泥于此公式。 请尝试:
Sub RHeader()
With Worksheets(Sheet1)。PageSetup
.RightHeader =&Courier New ,Bold& 12& KFF0000_
&工作表(合规性报告)。范围(a99)和Chr(10)_
& &新快递,常规& 10& K000000_
&工作表(合规性报告)。范围(a100)
结束于
结束小组
10
和 12
是字体大小, KFF0000
是红色的,希望其余的是不言而喻的和可调整的。
I would like to take a cell reference to another worksheet and put that in the center header and format it to a specific font and size.Next, I'd like to take the Right header and have either the name of my report as the top, with a bold font of specific size while the line below has a separate size and is not bold. Like below:
Compliance Report (This doesn't need to be cell referenced, it can stay the same).
Policy Date 2014 | 9/30/15 (This changes from account to account and need to come from a source range.)
I started with this code:
Sub header()
With Worksheets("Sheet1").PageSetup
.RightHeader = Worksheets("Compliance Report").Range("a99") _
& Chr(10) & Worksheets("Compliance Report").Range("a100")
End With
End Sub
It works for getting the data on two lines, but I can't format it. I'm not tied to sticking with this formula if there is a better option.
Please try:
Sub RHeader()
With Worksheets("Sheet1").PageSetup
.RightHeader = "&""Courier New,Bold""&12&KFF0000" _
& Worksheets("Compliance Report").Range("a99") & Chr(10) _
& "&""Courier New,Regular""&10&K000000" _
& Worksheets("Compliance Report").Range("a100")
End With
End Sub
10
and 12
are the font sizes, KFF0000
is red, hopefully the rest self-explanatory and adjustable.
这篇关于页眉页脚格式和公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!