Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6600557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:38:19+00:00 2026-05-25T18:38:19+00:00

I am totally new to MS Excel and VBA Macro. I wanna know how

  • 0

I am totally new to MS Excel and VBA Macro. I wanna know how to format cells or have an overall control on the spreadsheet using Macro VB. I have here a very simple code just to illustrate what I want to know.

macro_format_test.xlsm:

Private Sub Worksheet_Activate()
    Me.Unprotect
    Me.Cells.ClearContents

    Dim ws As Worksheet
    Set ws = Worksheets("Sheet1")

    ws.Cells(1, 1) = "ID"
    ws.Cells(1, 2) = "Name"
    ws.Cells(1, 3) = "Address"

    Me.Protect
End Sub

In the codes…

ws.Cells(1, 1) = "ID"
ws.Cells(1, 2) = "Name"
ws.Cells(1, 3) = "Address"

I want those to appear bold, italized, and centered. I also want to set he column width using codes. How am I gonna do that??? Please help. You can also give me some references regarding this because everytime I try google all I can see are how to add UserForm which I don’t need as of now. Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T18:38:20+00:00Added an answer on May 25, 2026 at 6:38 pm
    With Range("A1:C1")
        .HorizontalAlignment = xlCenter
        .Font.Italic = True
        .Font.Bold = True
        .EntireColumn.ColumnWidth = 15
    End With
    

    By the way, the easiest way to figure out what the macro would be for something like this is to Click the Record Macro button, make your changes manually, and then examine the code that was produced for you. It isn’t always the most efficient code, and you usually have to tweak it slightly, but it should give you a basic idea.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm totally new to Excel VBA. I am using Microsoft 2003 excel. What my
Totally new to programming so kindly excuse the silly question. I have this URL
Totally new to Capistrano. I have a local git repository that I want to
I'm totally new to AWS. I managed to have an instance that runs PHPMyAdmin.
First and foremost. I'm totally new to programming in Excel. I'm trying to make
Totally new to Drupal so be gentle please! Let's say I have a number
I am Totally new to Node.js, i have a node app running, but now
I'm totally new to Flex (moving away from Java for now :(). I have
Please note I'm totally new to ASP.NET.. How can I have the username, password
Alright totally new to jeditable, Say I have some <div> 's and <input type='hidden'

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.