+ Reply to Thread
Results 1 to 3 of 3

Thread: Macros and drop down boxes

  1. #1
    Registered User
    Join Date
    05-11-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    Macros and drop down boxes

    Hi Everyone,

    I have the following code working well in my worksheet but I would like it to be activated every time that a new selection is chosen by the user on a drop down list (located in cell C10) rather than having to create a seperate button.

    Please remember that I am very much a beginner so I will need step-by-step instructions on how to perform this action.

    Thank you in advance

    Here is the code.

    
    Sub Autofix()
    '
    ' Autofix Macro
    ' Macro recorded 12/05/2009 by Sean Hughes
    '
    ' Keyboard Shortcut: Ctrl+a
    '
        Range("B193").Select
        Selection.Rows.Autofit
        Range("B193:J193").Select
        With Selection
            .HorizontalAlignment = xlCenter
            .VerticalAlignment = xlTop
            .WrapText = True
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
            .MergeCells = False
        End With
        Selection.Merge
        With Selection
            .HorizontalAlignment = xlLeft
            .VerticalAlignment = xlTop
            .WrapText = True
            .Orientation = 0
            .AddIndent = False
            .IndentLevel = 0
            .ShrinkToFit = False
            .ReadingOrder = xlContext
            .MergeCells = True
        End With
        
    End Sub

  2. #2
    Forum Guru, retired Admin royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    25,639

    Re: Macros and drop down boxes

    You want to avoid merging cells they will eventually cause you problems in either vba or worksheet functions
    Hope that helps.

    RoyUK
    --------
    If you are pleased with a member's answer then use the Star icon to rate it, if you are pleased enough to part with cash consider a donation to Children in Need

    For Excel Tips & Solutions, free examples and tutorials why not check out my downloads

    New members please read & follow the Forum Rules

    Remember to mark your questions Solved and rate the answer(s)

  3. #3
    Registered User
    Join Date
    05-11-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Macros and drop down boxes

    Thanks for your help Roy but my document contains huge amounts of straight text and therefore I need merged cells in order to keep the paragraph formatting consistent.
    In any case my code works really well. All I need is for it to be launched when I select a new option on my drop down box.
    Does anyone have an answer for me? I would be very appreciative.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0