Adding formatting to VBA code

J

JRD

With some great help from this forum, I was able to add the followin
code:

Sub Total_Building_Damages()

Selection.Font.Bold = True
Selection.Font.Underline = xlUnderlineStyleSingle
With Selection
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
End With
ActiveCell.FormulaR1C1 = "Total Building Damages:"

End Sub

This works just fine. However, I would like to refine it a bit.

If I run this in A:9 for example, I would like F:9 and F:10 to b
double underlined and emboldened, without changing the formula in thos
cells. Ditto if I run it in A:11, then I would like F:11 and F:12 t
have this formatting. Any help?

Thanks for your time.


Ji
 
F

Frank Kabel

Hi
try
Sub Total_Building_Damages()
with activecell.offset(0,5).resize(2,1)
.Font.Bold = True
.Font.Underline = xlUnderlineStyleSingle
.HorizontalAlignment = xlRight
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = True
.Value = "Total Building Damages:"
End With

End Sub
 
J

JRD

Thanks for your quick reply, Frank, but I guess I wasn't clear.

I need for the current procedure to run just as it does. That is, i
the active cell is A:9, then I need for it to enter "Total Buildin
Damages" (Underlined and Emboldened) in that cell. I then need fo
cell A:11 to be double underlined and emboldened, but no value place
in it. I need the same formatting for cell A:12, but again, with n
values. Those cells (A:11 & A:12) have formulas in them and I don'
want those formulas disturbed.

Am I making sense?

Thanks,


Ji
 
F

Frank Kabel

Hi
then try:
Sub Total_Building_Damages()
with activecell
.Font.Bold = True
.Font.Underline = xlUnderlineStyleSingle
.Value = "Total Building Damages:"
end with

with activecell.offset(0,5).resize(2,1)
.Font.Bold = True
.Font.Underline = xlUnderlineStyleSingle
End With

End Sub
 
J

JRD

I gave you some bum info, but your examples got me on the right track.
Saved me a lot of time and I appreciate it.


Jim
 
Top