Editing this Macro to include Row 1

ChiTown

New Member
Joined
Mar 31, 2011
Messages
16
Hello,

Forgive me as I know nothing about the VBA language.

Can you please edit the following code to select and only format Row 1 with the following formatting?

Sub HeaderFormat()
'
' header Macro
'
' Keyboard Shortcut: Ctrl+h
'
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Selection.Font.Bold = True
With ActiveWindow
.SplitColumn = 0
.SplitRow = 1
End With
ActiveWindow.FreezePanes = True
End Sub
 
Last edited:

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Hi
This will do the ENTIRE row, which I'm guessing is not what you really need.
How many columns do you want this to apply to rather than the entire row??
Code:
Sub HeaderFormat()
' header Macro
' Keyboard Shortcut: Ctrl+h
With Rows(1).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
End With
Selection.Font.Bold = True
With ActiveWindow
.SplitColumn = 0
.SplitRow = 1
End With
ActiveWindow.FreezePanes = True
End Sub
 
Upvote 0
Hello Michael,

I just want this to apply to Row 1 but in every column as sometimes I have more columns than others.

I use this to format the header (which is always row 1 for me).

This is working but it's no bolding the text.
 
Last edited:
Upvote 0
Oops, my bad on the BOLD...I missed it, sorry !!
Dryver has covered it, but just in case you don't know how to do it !!
Code:
Sub HeaderFormat()
' header Macro
' Keyboard Shortcut: Ctrl+h
With Rows(1).Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
End With
Rows(1).Font.Bold = True
With ActiveWindow
.SplitColumn = 0
.SplitRow = 1
End With
ActiveWindow.FreezePanes = True
End Sub
 
Upvote 0
No worries Michael.

Thank you so much Dryver14 and Michael. You guys rock!!

Appreciate you spelling out for me too Michael. I'm getting used to the code.

Where is the best place to learn VBA 101 so that I can get a basic understanding of it?
 
Upvote 0
Practice, practice, practice.
1. Hang around here and read the posts. copy and paste the code to your practice sheets, and try them out.
2. Make changes to the sample codes and see what happens.
3. Ask lots of questions here.
4. Do a google for "Learn VBA for Excel"
5. Play with the macro recorder. Record some tasks and then look at the code to see how it works, then modify it and see what happens.

Unless you have a project to apply the VBA it is a bit hard to "learn", so be patient AND find a project that you could automate and do bit at a time from there.
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,351
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top