+ Reply to Thread
Results 1 to 5 of 5

Row Range Selection From ActiveCell

Hybrid View

werko Row Range Selection From... 01-17-2018, 02:03 AM
AlphaFrog Re: Row Range Selection From... 01-17-2018, 02:23 AM
werko Re: Row Range Selection From... 01-17-2018, 02:45 AM
AlphaFrog Re: Row Range Selection From... 01-17-2018, 02:54 AM
werko Re: Row Range Selection From... 01-17-2018, 05:08 AM
  1. #1
    Forum Contributor
    Join Date
    08-18-2009
    Location
    Chih, Mexico
    MS-Off Ver
    Excel 2010
    Posts
    102

    Row Range Selection From ActiveCell

    Hi,
    Need help!
    To solve this macro, it's giving me an error when I try to select a range in active row with activecell
    the purpose of this macro it's move down a row range in sheet2 when right click in cell B2 event is triggered on sheet1.

    Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
    If Intersect(Target, Range("B2")) Is Nothing Then
    Else
    With Worksheets("Sheet2")
        .Activate
        .Range(Target.Address).Offset(-1, 0).Select
    Dim lastRow As Long
    lastRow = ActiveCell.End(xlRight).Row
    Range(ActiveCell, ActiveCell.Offset(lastRow, 0)).Select
    ActiveCell.Offset(2, 0).Insert Shift:=xlDown
    ActiveCell.Offset(1, 0).Select
    End With
    End If
    End Sub
    Thanks, in advance...

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Row Range Selection From ActiveCell

    I don't know if this produces the result you want, but it wont error.

    Private Sub Worksheet_BeforeRightClick(ByVal Target As Range, Cancel As Boolean)
        If Not Intersect(Target, Range("B2")) Is Nothing Then
            With Worksheets("Sheet2")
                .Activate
                .Range(Target.Address).Offset(-1, 0).Select
                Dim lastRow As Long
                lastRow = ActiveCell.End(xlToRight).Row
                .Range(ActiveCell, ActiveCell.Offset(lastRow, 0)).Select
                ActiveCell.Offset(2, 0).Insert Shift:=xlDown
                ActiveCell.Offset(1, 0).Select
            End With
        End If
    End Sub
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Forum Contributor
    Join Date
    08-18-2009
    Location
    Chih, Mexico
    MS-Off Ver
    Excel 2010
    Posts
    102

    Re: Row Range Selection From ActiveCell

    Thanks, AlphaFrog.
    I don't have any error but i'll want to cut from range (B1:J1) then insert shift down that range
    but only move's cell's B1...

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,651

    Re: Row Range Selection From ActiveCell

    Quote Originally Posted by werko View Post
    Thanks, AlphaFrog.
    I don't have any error but i'll want to cut from range (B1:J1) then insert shift down that range
    but only move's cell's B1...
    I don't know what that means.

  5. #5
    Forum Contributor
    Join Date
    08-18-2009
    Location
    Chih, Mexico
    MS-Off Ver
    Excel 2010
    Posts
    102

    Re: Row Range Selection From ActiveCell

    Sample file attached with desired result.
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copying an activecell range and pasting to another activecell range
    By Londonbound in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-12-2014, 07:41 AM
  2. Get Listbox Selection into the ActiveCell
    By matth3881 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-28-2014, 08:19 AM
  3. [SOLVED] Question on ActiveCell.Value And Selection
    By JM967 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-26-2013, 08:32 PM
  4. controling activecell in a selection through macros
    By Suraj3825 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2013, 08:32 AM
  5. Performing an action on a selection (ActiveCell?)
    By Glooms in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-10-2009, 03:56 AM
  6. Selection.Autofill Destination:=Range(ActiveCell.Value)
    By Shaka215@gmail.com in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-23-2006, 06:20 PM
  7. [SOLVED] Delete all entries in selection except activecell
    By Elaine in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-10-2005, 04:06 PM

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