+ Reply to Thread
Results 1 to 5 of 5

Paste defined variable into cell range

  1. #1
    Forum Contributor
    Join Date
    02-16-2006
    Posts
    241

    Paste defined variable into cell range

    I use the following code to copy and paste cells into a cell range:

    Please Login or Register  to view this content.
    I would like to paste a variable into the range instead of the data contained in cells (A9, A10, A11, etc.) but based on the number of rows containing data.

    Example if cells (A9, A10, & A11) contain data & A12 is blank. My variable will be pasted into the active cells (C1,C2, & C3). It will also be able to handle a single cell of data, like the above code. Using the previous example, if data is contained only in cell A9 then my variable will be pasted in C1.

    Any help would be appreciated.


    Thanks,

    Met

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,990

    Re: Paste defined variable into cell range

    Please Login or Register  to view this content.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Forum Contributor
    Join Date
    02-16-2006
    Posts
    241

    Re: Paste defined variable into cell range

    Bernie,

    Thanks for your response. The above code works perfectly. How would you apply this to the activecell as opposed to C1?


    Thanks,

    Met

  4. #4
    Forum Contributor
    Join Date
    02-16-2006
    Posts
    241

    Re: Paste defined variable into cell range

    Bernie,

    Disregard the previous post. I figured out my problem. (Hit a . instead of a ,) Following is what I used.

    Please Login or Register  to view this content.
    Thanks again for your help,

    Met

  5. #5
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,990

    Re: Paste defined variable into cell range

    Actually, that all simplifies to just

    ActiveCell.Resize(lastrow - 8).Value = varName

+ 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. 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
  2. [SOLVED] Paste a value in the next empty cell for a defined range
    By aadeshgandhi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-13-2013, 08:53 PM
  3. Macro to Insert defined integer into range defined by variable criteria
    By stereofeedback in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-06-2013, 12:33 PM
  4. [SOLVED] Using cell value to define a range (for a variable defined as a range)
    By Sccye in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 04-02-2012, 10:25 AM
  5. EXCEL 2003 copy paste a defined range in a cell
    By EXCELNOOB123 in forum Excel General
    Replies: 1
    Last Post: 03-07-2011, 10:01 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