+ Reply to Thread
Results 1 to 5 of 5

How to add one column to a range VBA

Hybrid View

  1. #1
    in-over-his-head-bill
    Guest

    How to add one column to a range VBA

    Sorry to be so thick, but I am really struggling with how to correctly
    specify ranges.
    I dumped a recordset (which will have varying sizes in my application) onto
    a worksheet beginning at cell A25. What I want to do is have a named range
    for the results I put on the worksheet plus one additional column.

    I've got the getting the results into the range down with the code below.
    How do I get an extra column into the range?

    Dim rng As Range
    Set rng =
    Worksheets("programws").Range("A25").End(xlDown).End(xlToRight).CurrentRegion
    rng.Name = "reportcontrol"


  2. #2
    Ardus Petus
    Guest

    Re: How to add one column to a range VBA

    Dim rng As Range
    Set rng =
    Worksheets("programws").Range("A25").End(xlDown).End(xlToRight).CurrentRegion
    set rng=rng.resize(rng.rows+1)
    rng.Name = "reportcontrol"

    "in-over-his-head-bill" <[email protected]> a
    écrit dans le message de news:
    [email protected]...
    > Sorry to be so thick, but I am really struggling with how to correctly
    > specify ranges.
    > I dumped a recordset (which will have varying sizes in my application)
    > onto
    > a worksheet beginning at cell A25. What I want to do is have a named range
    > for the results I put on the worksheet plus one additional column.
    >
    > I've got the getting the results into the range down with the code below.
    > How do I get an extra column into the range?
    >
    > Dim rng As Range
    > Set rng =
    > Worksheets("programws").Range("A25").End(xlDown).End(xlToRight).CurrentRegion
    > rng.Name = "reportcontrol"
    >




  3. #3
    Bob Phillips
    Guest

    Re: How to add one column to a range VBA

    Set rng = _
    Worksheets("programws").Range("A25").End(xlDown).End(xlToRight).CurrentRegio
    n
    Set rng = rng.Resize(, rng.Columns.Count + 1)
    rng.Name = "reportcontrol"


    --
    HTH

    Bob Phillips

    (replace somewhere in email address with gmail if mailing direct)

    "in-over-his-head-bill" <[email protected]> wrote
    in message news:[email protected]...
    > Sorry to be so thick, but I am really struggling with how to correctly
    > specify ranges.
    > I dumped a recordset (which will have varying sizes in my application)

    onto
    > a worksheet beginning at cell A25. What I want to do is have a named range
    > for the results I put on the worksheet plus one additional column.
    >
    > I've got the getting the results into the range down with the code below.
    > How do I get an extra column into the range?
    >
    > Dim rng As Range
    > Set rng =
    >

    Worksheets("programws").Range("A25").End(xlDown).End(xlToRight).CurrentRegio
    n
    > rng.Name = "reportcontrol"
    >




  4. #4
    in-over-his-head-bill
    Guest

    Re: How to add one column to a range VBA

    Thanks to you both for getting me through the mental block.

    "Bob Phillips" wrote:

    > Set rng = _
    > Worksheets("programws").Range("A25").End(xlDown).End(xlToRight).CurrentRegio
    > n
    > Set rng = rng.Resize(, rng.Columns.Count + 1)
    > rng.Name = "reportcontrol"
    >
    >
    > --
    > HTH
    >
    > Bob Phillips
    >
    > (replace somewhere in email address with gmail if mailing direct)
    >
    > "in-over-his-head-bill" <[email protected]> wrote
    > in message news:[email protected]...
    > > Sorry to be so thick, but I am really struggling with how to correctly
    > > specify ranges.
    > > I dumped a recordset (which will have varying sizes in my application)

    > onto
    > > a worksheet beginning at cell A25. What I want to do is have a named range
    > > for the results I put on the worksheet plus one additional column.
    > >
    > > I've got the getting the results into the range down with the code below.
    > > How do I get an extra column into the range?
    > >
    > > Dim rng As Range
    > > Set rng =
    > >

    > Worksheets("programws").Range("A25").End(xlDown).End(xlToRight).CurrentRegio
    > n
    > > rng.Name = "reportcontrol"
    > >

    >
    >
    >


  5. #5
    Don Guillett
    Guest

    Re: How to add one column to a range VBA

    try
    toright).offset(,1)

    --
    Don Guillett
    SalesAid Software
    [email protected]
    "in-over-his-head-bill" <[email protected]> wrote
    in message news:[email protected]...
    > Sorry to be so thick, but I am really struggling with how to correctly
    > specify ranges.
    > I dumped a recordset (which will have varying sizes in my application)
    > onto
    > a worksheet beginning at cell A25. What I want to do is have a named range
    > for the results I put on the worksheet plus one additional column.
    >
    > I've got the getting the results into the range down with the code below.
    > How do I get an extra column into the range?
    >
    > Dim rng As Range
    > Set rng =
    > Worksheets("programws").Range("A25").End(xlDown).End(xlToRight).CurrentRegion
    > rng.Name = "reportcontrol"
    >




+ 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