Results 1 to 6 of 6

write selected range to variable and then write the range saved in variable in to a cell

Threaded View

  1. #1
    Registered User
    Join Date
    01-29-2020
    Location
    Berlin, Germany
    MS-Off Ver
    2016
    Posts
    5

    write selected range to variable and then write the range saved in variable in to a cell

    Hi everybody,

    How can I write the saved cell range of a variable in a cell?
    For example:

    Dim rng As Range 'this works fine

    Set rng = Selection 'this works fine

    Range("O1").Value = rng 'this does not work, the cell is still blank after that


    Also if I use a msgBox to see if the range is getting stored in my rng var, its shown.
    So it seems to be an issue with the last line, is it even possible to write a range var in to a cell?

    I somehow need a solution to save the range of already selected cells in a worksheet to a variable.
    Then I want to write the content of the variable (for example: A1:B5) in to a cell in the same worksheet.
    Background: I want to use the cell range later on for a range selection, so after the steps above, I want to save the cell range(example: A1:B5) again in a var to use for selection.
    The problem is that, the workbook is getting closed in between saving and using the content of variable, so because of that I want to go for this workaround.
    Last edited by ExcelBobb; 02-20-2020 at 04:35 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Method `Range of object_'Worksheet' failed - Trying to write variable to cell
    By stevemcd1 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-17-2013, 04:52 PM
  2. Get multiple user selected cell range addresses and write to dictionary
    By aznenginerd in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-28-2012, 05:49 PM
  3. Write variable to cell in excel
    By iisjman07 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-27-2010, 07:22 PM
  4. Trying to 'write' a formula in a cell with a variable reference
    By stumpy in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-12-2007, 09:33 PM
  5. [SOLVED] using code variable to write cell formula
    By rpw in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-05-2006, 02:00 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