+ Reply to Thread
Results 1 to 3 of 3

Thread: rewrite in range

  1. #1
    ina
    Guest

    rewrite in range

    Hello,

    I have this piece of code that each time that sets a range and assign
    this data to the range.

    Dim rngNextCell As Range
    Set rngNextCell = Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)


    rngNextCell.Resize(UBound(vartbl, 1) - LBound(vartbl, 1) + 1,
    UBound(vartbl, 2) - LBound(vartbl, 2) + 1).Value = vartbl


    What I would like to do it that the next time a run this macro, the
    actual range will be rewrited by the new range


  2. #2
    Tom Ogilvy
    Guest

    RE: rewrite in range

    Dim rngNextCell As Range
    Dim r as Range
    on Error Resume Next
    set rngNextCell = Range("MyData").RefersToRange
    On Error goto 0
    if rngNextCell is nothing then
    Set rngNextCell = Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
    End if

    set r = rngNextCell(1).Resize(UBound(vartbl, 1) - LBound(vartbl, 1) + 1,
    UBound(vartbl, 2) - LBound(vartbl, 2) + 1).Value

    r = vartbl
    r.Name = "MyData"

    --
    Regards,
    Tom Ogilvy


    "ina" wrote:

    > Hello,
    >
    > I have this piece of code that each time that sets a range and assign
    > this data to the range.
    >
    > Dim rngNextCell As Range
    > Set rngNextCell = Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
    >
    >
    > rngNextCell.Resize(UBound(vartbl, 1) - LBound(vartbl, 1) + 1,
    > UBound(vartbl, 2) - LBound(vartbl, 2) + 1).Value = vartbl
    >
    >
    > What I would like to do it that the next time a run this macro, the
    > actual range will be rewrited by the new range
    >
    >


  3. #3
    ina
    Guest

    Re: rewrite in range

    thank you tom


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