+ Reply to Thread
Results 1 to 8 of 8

Outputting from VBA to multiple cells at once

  1. #1
    Registered User
    Join Date
    03-12-2017
    Location
    Galway
    MS-Off Ver
    Excel 2016
    Posts
    24

    Unhappy Outputting from VBA to multiple cells at once

    So i've a worksheet that contains a template that is filled up using a few user forms via vba.

    Currently im using
    Please Login or Register  to view this content.
    to output data thats been inputted into the userform textboxes.

    Im also renaming single cells to avoid having to hardcode cell references everytime I make a change to the number of rows/cols etc.

    The problem im having is that I have a lot of cells to rename, I cannot just select a large range and rename them, the cells are not all next to one and other.

    Is there a way to rename multiple cells for referencing when I want to output data to the sheet, i.e. have 3 cells named " ExampleData " and in my vba code when I execute:
    Please Login or Register  to view this content.
    it outputs the same info inputted into textbox1, but to 3 different cells?


    Sorry if this sounds confusing or doesnt make sense. Just want to be able to output to non-contiguous cells at the same time!

    Thanks
    Tom

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Outputting from VBA to multiple cells at once

    I am not sure what the question is..Range("ExampleData").value = textbox1 will populate non-contiguous cells.

    I don't know how you think we would be able to figure out how to select your cells and name them based on the information you supplied.

  3. #3
    Registered User
    Join Date
    03-12-2017
    Location
    Galway
    MS-Off Ver
    Excel 2016
    Posts
    24

    Re: Outputting from VBA to multiple cells at once

    So I have 4 cells, A1, D3, E7 and G6.

    I want to populate them all at the same time, I populate one. I know I can do this via
    Please Login or Register  to view this content.
    But what I want to be able to do is do it on one line, under one named range. i.e.,
    Please Login or Register  to view this content.
    And from this line being execute, all 4 cells are populated.

    I apologise for being unclear, im very new to vba!

    Tom

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Outputting from VBA to multiple cells at once

    Your code should work, if it doesn't, supply a sample workbook

  5. #5
    Registered User
    Join Date
    03-12-2017
    Location
    Galway
    MS-Off Ver
    Excel 2016
    Posts
    24

    Re: Outputting from VBA to multiple cells at once

    Quote Originally Posted by davesexcel View Post
    Your code should work, if it doesn't, supply a sample workbook
    I understand that writing out one statement per cell will work. But I want to be able to group all 4 cells, under a single name and output 4 lots of identical data, from one line of code via the named range.

    Can it be done is what Im asking? I dont really know as my knowledge is limited in vba, and im looking to do things quicker rather than slog through it all slowly!
    Attached is a short sample of what I have, and need to change!

    Thanks.
    Attached Files Attached Files

  6. #6
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Outputting from VBA to multiple cells at once

    Try:-
    Please Login or Register  to view this content.
    Regards Mick

  7. #7
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,525

    Re: Outputting from VBA to multiple cells at once

    You did not name the range in your sample, you said you had 3 cells named "ExampleData", you say the code does not work, you have supplied a sample workbook, and there are no named ranges. That would be why the code does not work.

    Anyway,
    Name the range and run the code.

    you can also use,
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    03-12-2017
    Location
    Galway
    MS-Off Ver
    Excel 2016
    Posts
    24
    Quote Originally Posted by davesexcel View Post
    You did not name the range in your sample, you said you had 3 cells named "ExampleData", you say the code does not work, you have supplied a sample workbook, and there are no named ranges. That would be why the code does not work.

    Anyway,
    Name the range and run the code.

    you can also use,
    Please Login or Register  to view this content.
    I never said my code didn't work, I said it was not as efficient as what I wanted.
    All I want to know is if you can rename multiple cells, that are not adjacent to each other, as the same name. For example can I rename the 4 in the sample I uploaded, under the same name, and then reference these in a function?

+ 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. Outputting individual cells to individual text files
    By db9429 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-17-2013, 03:39 PM
  2. Replies: 0
    Last Post: 09-10-2012, 09:34 PM
  3. [SOLVED] Outputting different values depending on which text value of multiple is found in a string
    By RichieAHB in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 08-15-2012, 12:15 PM
  4. List Box Selections Outputting Multiple Selections with One Click
    By Mordred in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 07-21-2011, 12:27 PM
  5. sorting a dynamic range from smallest to largest and outputting in cells
    By mashoutposse in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-02-2010, 08:23 PM
  6. outputting an array
    By demuro1 in forum Excel General
    Replies: 2
    Last Post: 10-05-2008, 09:54 PM
  7. outputting data
    By excelguru in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-06-2008, 02:59 AM
  8. [SOLVED] outputting to multiple worksheets
    By cmumeche in forum Excel General
    Replies: 0
    Last Post: 07-29-2005, 04:05 PM

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