Consulting

Results 1 to 3 of 3

Thread: Solved: Select numerous cells from active cell

  1. #1
    VBAX Regular
    Joined
    Nov 2006
    Posts
    81
    Location

    Solved: Select numerous cells from active cell

    Hi

    I would like to find out how do I change a macro to work from the active cell. The recorded Macro looks like this.....
    [VBA]Sub Macro2()
    ' Macro2 Macro
    Range("J9:O24").Select
    With Selection
    .HorizontalAlignment = xlCenter
    .VerticalAlignment = xlBottom
    .WrapText = False
    .Orientation = 0
    .AddIndent = False
    .IndentLevel = 0
    .ShrinkToFit = False
    .ReadingOrder = xlContext
    .MergeCells = False
    End With
    Selection.Merge
    End Sub[/VBA]

    Now where it selects the Range, I would like to select 3 cells right and 8 cells down, and then merge the whole lot. Then you could select any cell in w/s and run the macro.

    Thank you

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]Sub Macro2()
    With ActiveCell.Resize(8, 3)
    .HorizontalAlignment = xlCenter
    .VerticalAlignment = xlBottom
    .WrapText = False
    .Orientation = 0
    .AddIndent = False
    .IndentLevel = 0
    .ShrinkToFit = False
    .ReadingOrder = xlContext
    .MergeCells = True
    End With
    End Sub
    [/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Regular
    Joined
    Nov 2006
    Posts
    81
    Location
    Thank you mdmackillop.

    Perfect.

Posting Permissions

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