Results 1 to 13 of 13

VBA - Define Selection using cell reference

Threaded View

  1. #4
    Forum Expert GeneralDisarray's Avatar
    Join Date
    09-15-2011
    Location
    Pittsburgh, PA, USA
    MS-Off Ver
    Windows Excel 2016
    Posts
    1,416

    Re: VBA - Define Selection using cell reference

    Yes, you can do that. See the attached example (I'm putting the values in F2 for the example)


    Option Explicit
    Sub pasteChoosenRows()
    Dim rowsToUse As Long
    Dim source As Range, destination As Range
    
    
    'Adjust these to the real sheet'
    rowsToUse = ActiveSheet.Range("F1").Value
    Set source = ActiveSheet.Range("A2")
    Set destination = ActiveSheet.Range("F2")
    
    'Align the values'
    
    destination.Resize(rowsToUse, source.End(xlToRight).Column - source.Column + 1).Value = _
    source.Resize(rowsToUse, source.End(xlToRight).Column - source.Column + 1).Value
    
    End Sub
    Attached Files Attached Files
    Remember, saying thanks only takes a second or two. Click the star icon(*) below the post you liked, to give some Rep if you think an answer deserves it.

    Please,mark your thread [SOLVED] if you received your answer.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Different sheet refernce using a formula to define the cell reference
    By tritty in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-06-2013, 11:16 PM
  2. [SOLVED] Use Cell Reference to Define Sum Ranges Across Different Sheets
    By jwhite0720 in forum Excel General
    Replies: 2
    Last Post: 06-29-2012, 11:34 AM
  3. How to define a cell name and reference it in a differen sheet
    By shaunsul in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-26-2011, 01:27 PM
  4. Define Name to current selection
    By azureriders in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-02-2008, 11:02 PM
  5. Define Name to current selection
    By Eduard in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-25-2008, 10:58 AM

Tags for this Thread

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