+ Reply to Thread
Results 1 to 4 of 4

Thread: Selecting a cell in a row just inserted in a range.

  1. #1
    Shannon
    Guest

    Selecting a cell in a row just inserted in a range.

    I'm trying to select a cell in column 2 of a row that is just inserted into a
    range using a macro. After searching the group discussion, I found and
    modified this script to actually insert the row. I now need to modify it to
    select the cell (make it active) in column 2 of the row that was just
    inserted. This macro is started with a button and the active cell could be
    anywhere when the button is pressed.

    Here's the code I'm starting with to insert a row:

    Dim DGrng As Range
    Set DGrng = Range("DG")
    Set DGrng = DGrng.Rows(DGrng.Rows.Count)
    Sheets("Preliminary Report").Unprotect
    DGrng.EntireRow.Insert
    Sheets("Preliminary Report").Protect


    Thanks in Advance!

  2. #2
    Don Guillett
    Guest

    Re: Selecting a cell in a row just inserted in a range.

    Try this. Be advised that it is almost always NOT necessary to select
    anything.

    Sub insertrowandgo()
    Cells(Range("myrng").Rows.Count, 2).Select
    Selection.EntireRow.Insert
    End Sub

    --
    Don Guillett
    SalesAid Software
    dguillett1@austin.rr.com
    "Shannon" <Shannon@discussions.microsoft.com> wrote in message
    news:C34520D8-0C62-4815-B7FC-34F75FC5D09C@microsoft.com...
    > I'm trying to select a cell in column 2 of a row that is just inserted
    > into a
    > range using a macro. After searching the group discussion, I found and
    > modified this script to actually insert the row. I now need to modify it
    > to
    > select the cell (make it active) in column 2 of the row that was just
    > inserted. This macro is started with a button and the active cell could
    > be
    > anywhere when the button is pressed.
    >
    > Here's the code I'm starting with to insert a row:
    >
    > Dim DGrng As Range
    > Set DGrng = Range("DG")
    > Set DGrng = DGrng.Rows(DGrng.Rows.Count)
    > Sheets("Preliminary Report").Unprotect
    > DGrng.EntireRow.Insert
    > Sheets("Preliminary Report").Protect
    >
    >
    > Thanks in Advance!




  3. #3
    Shannon
    Guest

    Re: Selecting a cell in a row just inserted in a range.

    Thanks Don,

    I said "select", maybe needed to say "activate". Basically, I'm setting it
    up so that information can be placed into the new row that comes from three
    InputBoxes.

    But... that's all moot now. I'm now getting an Error 1004 "Insert method of
    Range class failed" on this code and another code that I haven't changed.

    Don't know what happened; but something did. The code was working fine last
    night.

    "Don Guillett" wrote:

    > Try this. Be advised that it is almost always NOT necessary to select
    > anything.
    >
    > Sub insertrowandgo()
    > Cells(Range("myrng").Rows.Count, 2).Select
    > Selection.EntireRow.Insert
    > End Sub
    >
    > --
    > Don Guillett
    > SalesAid Software
    > dguillett1@austin.rr.com
    > "Shannon" <Shannon@discussions.microsoft.com> wrote in message
    > news:C34520D8-0C62-4815-B7FC-34F75FC5D09C@microsoft.com...
    > > I'm trying to select a cell in column 2 of a row that is just inserted
    > > into a
    > > range using a macro. After searching the group discussion, I found and
    > > modified this script to actually insert the row. I now need to modify it
    > > to
    > > select the cell (make it active) in column 2 of the row that was just
    > > inserted. This macro is started with a button and the active cell could
    > > be
    > > anywhere when the button is pressed.
    > >
    > > Here's the code I'm starting with to insert a row:
    > >
    > > Dim DGrng As Range
    > > Set DGrng = Range("DG")
    > > Set DGrng = DGrng.Rows(DGrng.Rows.Count)
    > > Sheets("Preliminary Report").Unprotect
    > > DGrng.EntireRow.Insert
    > > Sheets("Preliminary Report").Protect
    > >
    > >
    > > Thanks in Advance!

    >
    >
    >


  4. #4
    Shannon
    Guest

    Re: Selecting a cell in a row just inserted in a range.

    Shannon says to hisself, "Doh! Unprotect the sheet moron!"

    > But... that's all moot now. I'm now getting an Error 1004 "Insert method of
    > Range class failed" on this code and another code that I haven't changed.
    >
    > Don't know what happened; but something did. The code was working fine last
    > night.
    >


+ 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