+ Reply to Thread
Results 1 to 9 of 9

How to format a code in module? Guidance please!

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    How to format a code in module? Guidance please!

    Hi friends,
    I have inserted a module in a workbook.
    Wrote a code for a macro.
    The code is not left align.
    I want to align it left.
    To do it I select all the code and then in format tab I go to sub menu of format align left.
    But the align left and all other options are not available. So I'm unable to align the code left.

    Please suggest me a proper way to achieve the target.

    Thanking you,
    Sincerely,

    mso3

  2. #2
    Forum Expert Debraj Roy's Avatar
    Join Date
    09-27-2012
    Location
    New Delhi,India
    MS-Off Ver
    Excel 2013
    Posts
    1,469

    Re: How to format a code in module? Guidance please!

    Alignment option is applicable for User Form controls.. like buttons, combobox..

    Did you tried..
    by pressing TAB / Shift + TAB..
    In menu Section > EDIT Meny > then INDENT also available for mouse click..
    Regards!
    =DEC2HEX(3563)

    If you like someone's answer, click the star to give them a reputation point for that answer...

  3. #3
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: How to format a code in module? Guidance please!

    In the VBEditor under Exel, the Preferences give you formatting options. It sounds like the margin indicator bar checkbox (Editor format tab) might be what you are looking for.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  4. #4
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,227

    Re: How to format a code in module? Guidance please!

    Hi mso,

    See this page for better discriptions.

    http://www.bettersolutions.com/vba/s...whitespace.htm
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  5. #5
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: How to format a code in module? Guidance please!

    Hi mikerickson,
    The margin indicator bar is checked but still the code is not in left align in the module. I select the extra spaces at left, delete it manually and manually align the code left align which is very laborious.

    So suggest me a best way to do it quickly.

    Thank you,

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,227

    Re: How to format a code in module? Guidance please!

    Hi mso,

    Select the entire Subroutine by left clicking and dragging over the entire thing. While it is selected, press Shift Tab. Do this multiple times and all indented text will move left. The distance it moves left is determined by your default settings in your VBA Editor Options. That is in VBA > Tools > Options > Editor Tab > Tab Width.

    Now select a few lines and while they are highlighted, click the tab key. What is selected will indent.

    I hope that makes sense.

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: How to format a code in module? Guidance please!

    Indentation in code is usually there to make it easier to read, is there a reason you want to remove it?

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,644

    Re: How to format a code in module? Guidance please!

    If you want help indenting code give this a go SmartIndenter.
    If posting code please use code tags, see here.

  9. #9
    Forum Contributor
    Join Date
    06-29-2014
    Location
    India
    MS-Off Ver
    2010 Windows 10 64 bits
    Posts
    1,269

    Re: How to format a code in module? Guidance please!

    Hi all,
    Thank you for your valuable kind guidance.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Code locks cells when inserted in sheet module but returns error in standard module
    By yoda66 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-07-2014, 07:39 AM
  2. how to access Sheet module, normal module, Worbook module to type code
    By alibaba in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-31-2009, 07:51 AM
  3. Replies: 4
    Last Post: 12-11-2005, 08:00 PM
  4. [SOLVED] Run worksheet module code from workbook module?
    By keithb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-14-2005, 12:05 AM
  5. Replies: 1
    Last Post: 04-10-2005, 07:07 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1