+ Reply to Thread
Results 1 to 4 of 4

Cut and Paste with User Defined Ranges in a macro

  1. #1
    Registered User
    Join Date
    07-06-2015
    Location
    Gig Harbor
    MS-Off Ver
    2007
    Posts
    4

    Cut and Paste with User Defined Ranges in a macro

    I am very new to VBA and I have done a lot of research to try and figure this out....but I am stumped and hope I can get some help. I want to cut a user-defined range from Column Q and paste to the same rows in Column O (same workbook). The range changes depending on which worksheet I am using. Here is what I have tried -- but its not working.

    Sub Macro4()
    '
    ' Macro4 Macro
    ' Cut A Section of Col Q and Move to Col O
    '
    ' Keyboard Shortcut: Ctrl+u
    '
    Dim Workbook As Workbook
    Dim QRange As Range
    Dim ORange As Range
    Set Workbook = ActiveWorkbook
    Set QRange = Application.InputBox(prompt:= _
    "Select Range", Type:=8)
    QRange.Select
    ActiveWorkbook.Worksheets("Sheet1").Range.Selection.Cut
    Set ORange = Application.InputBox(prompt:= _
    "Select Range", Type:=8)
    ActiveWorkbook.Worksheets("Sheet1").Range.Selection.Paste
    End Sub

    Any help I can get would be appreciated!

  2. #2
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Cut and Paste with User Defined Ranges in a macro

    Maybe something like this?

    Please Login or Register  to view this content.
    Last edited by NeedForExcel; 07-13-2015 at 12:06 AM.
    Cheers!
    Deep Dave

  3. #3
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: Cut and Paste with User Defined Ranges in a macro

    Hi,

    I have shortened the code a bit yet again.

    Also, please mark the thread as solved if you have your answer..

    And thank you for the rep!
    Last edited by NeedForExcel; 07-13-2015 at 12:08 AM.

  4. #4
    Registered User
    Join Date
    07-06-2015
    Location
    Gig Harbor
    MS-Off Ver
    2007
    Posts
    4

    Re: Cut and Paste with User Defined Ranges in a macro

    Thank you so much! This worked great!

+ 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. duplicates - user defined ranges - need help!
    By banks334 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-19-2014, 07:21 PM
  2. Combine VLOOKUP and SUMIF to return sum of user-defined ranges in a table
    By sciondraconis in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-27-2014, 03:27 AM
  3. Copy, paste, replace- user defined range in all the defined sheets
    By aganesan99 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-13-2014, 12:28 PM
  4. Paste to user defined cell
    By neobrainless in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-18-2012, 11:56 AM
  5. User Defined Functions: can control what named ranges get used?
    By djt76010 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-21-2008, 08:26 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