+ Reply to Thread
Results 1 to 2 of 2

Macro To Select variable range

Hybrid View

  1. #1
    Registered User
    Join Date
    04-14-2008
    Posts
    1

    Macro To Select variable range

    Hello!

    I would like to create macro which is doing following. Selects for example C3 cell then does shift+cntrl+down (xlDown, if i understand right) and then counts off last 3 rows.
    So I get whole rows in C column except last 3 ones. And i can format them further.

    as I understand i have to make some kind of variable and use something like
    Set x = C3.End(xlDown)
    but i have not a single idea about syntax and such things, I am newbie in VB code.

    Any help would be realy appreciated.
    Thank You!

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    You don't need to select a range to work with it. Try

    Option Explicit
    
    Sub varRange()
        Dim rng    As Range
    
        Set rng = Range(Cells(3, 3), Cells(Rows.Count, 3).End(xlUp))
        Set rng = rng.Resize(rng.Rows.Count - 3, rng.Columns.Count)
        MsgBox rng.Address
    End Sub
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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