vba font size/row&column width

kelvin_9

Active Member
Joined
Mar 6, 2015
Messages
444
Office Version
  1. 2019
greeting to all of you

i'm a beginner of vba, i've recorded some macro below to run my workbook, but i got some error with the outcome, can anyone with your kind guidance help me out?
my expectation are:
~ row 1 height was 100 instead of frist 3 rows
~ column A:H width was 80 instead of column D only 80 (*even column G:H width should be 15)
~ cell B1:F1 & cell B5:F5 should merged

*font size should be correct now
what did i wrong?

appreciate for the poor english

VBA Code:
Sub Macro1()
'
' Macro1 Macro
'

'
    ActiveWorkbook.Sheets.Select

    Cells.Select
    Cells.EntireRow.AutoFit

    Rows("9:38").Select
    Selection.RowHeight = 30
    Rows("1:1").Select
    Selection.RowHeight = 100
    Columns("G:H").Select
    Selection.ColumnWidth = 15

    Range("B1").Select
    With Selection.Font
        .Name = "Calibri"
        .Size = 80
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .Underline = xlUnderlineStyleNone
        .Color = -16777216
        .TintAndShade = 0
        .ThemeFont = xlThemeFontNone
    End With
    With Selection
        .HorizontalAlignment = xlGeneral
        .VerticalAlignment = xlCenter
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With

    Range("B1:F1").Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlTop
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Selection.Merge

    Range("B5:F5").Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlTop
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Selection.Merge

    Columns("B:B").EntireColumn.AutoFit
    Columns("D:D").Select
    Range("D2").Activate
    Selection.ColumnWidth = 80

    Range("A1").Select
End Sub
 
gordsky
thank you very much for all of this help

i'm still learning coding, even i dont understand too much of "dim ws as... dim wb as...... or next......" i can just record so i may have lot of unneeded as what you said
i'm sorry

now i can go to my next difficulties - color tab if found same result, and continue my workbook

thank you again
no problem, do come back to the site if you require further
 
Upvote 0

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.

Forum statistics

Threads
1,212,938
Messages
6,110,782
Members
448,297
Latest member
carmadgar

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