+ Reply to Thread
Results 1 to 7 of 7

Copy Variable to a Range of Cells

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

    Copy Variable to a Range of Cells

    I have a situation where I declare a variable via an input box and I want that variable to be copied to a range of cells in column E. (See attached sample) However, it only needs to copy the same number of rows in column D. In the attached example, I need the variable to be inserted into cells E3:E9. If column D more rows of text then column E would mimmick the row count but insert the input data into the column.

    Folowing is the code I have: (It only completes cell E3)

    Please Login or Register  to view this content.

    Any help would be appreciated.


    Thanks,

    Met
    Attached Files Attached Files

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Copy Variable to a Range of Cells

    Try:
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

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

    Re: Copy Variable to a Range of Cells

    Olly:

    Thank you for your response. The script you provided works. However, I failed to mention that new data will be entered into the spreadsheet and I need to retain the old values. In the sample provided, If I run the script it works great the first time. However, if I input new text into the spreadsheet(A10:D15) and run the script again, all the values in column E (E3:E) will be changed to the input variable. In the (A10:D15) case I could change the script to reflect:
    Please Login or Register  to view this content.
    but I do not want to modifiy my code each time. Any suggestions or help would be appreciated.


    Thanks,

    Met

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Copy Variable to a Range of Cells

    Try the attached.
    Attached Files Attached Files

  5. #5
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Copy Variable to a Range of Cells

    Change to:
    Please Login or Register  to view this content.

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Copy Variable to a Range of Cells

    Maybe:

    Please Login or Register  to view this content.

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

    Re: Copy Variable to a Range of Cells

    Thanks for the quick responses guys. Works 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. [SOLVED] copy common cells and variable range from multiple worksheets to single master workbook
    By tg7384 in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 04-15-2014, 03:05 PM
  2. Copy variable range from variable workbook to variable range on current workbook
    By Locster79 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-09-2013, 10:37 AM
  3. [SOLVED] Copy range from multiple sheets, into a master sheet and moving over by variable col range
    By g1eagle in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-23-2012, 01:36 PM
  4. [SOLVED] Copy/Paste Values from Variable Range to Corresponding Variable Range
    By Cpetersoc in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-14-2012, 08:20 AM
  5. Copy only Visible Cells of a Variable Range...
    By Damian Carrillo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-20-2005, 10:05 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