+ Reply to Thread
Results 1 to 20 of 20

How do I copy cells and remove blank?

  1. #1
    Registered User
    Join Date
    01-10-2018
    Location
    Ger
    MS-Off Ver
    365
    Posts
    11

    How do I copy cells and remove blank?

    I made a very simple picture for perfect explaining: https://i.imgur.com/wutI6sY.png

    I have 3 sheets:
    • sheet1: Here are my recipes (for example "Alpha" and "Beta")
    • sheet2: A big chart called ("Recipe (all ingredients)") with all ingredients listed.
    • sheet3: A chart that always uses the values from sheet2 but without the blank.

    What I want to do:
    • I go to sheet1 and click on the button below a recipe (for example "Alpha").
    • Now the values from "Alpha" should copy themselves to sheet2 but enter correctly, because there are all ingredients listed and Alpha uses only a few ingredients.
    • Now sheet2 has a lot of 0 values, because we don't need all ingredients now, but all are listed. Some got values from recipe "Alpha" and the rest has "0%".
    • Sheet3 checks always the list/chart "Recipe (all ingredients)" from sheet2 and only displays the "cells" aka "ingredients" with value.

    The picture explains it a lot better than I can do it with my words: https://i.imgur.com/wutI6sY.png

  2. #2
    Forum Expert
    Join Date
    11-27-2007
    Location
    New Jersey, USA
    MS-Off Ver
    2013
    Posts
    1,669

    Re: How do I copy cells and remove blank?

    attach excel file with data and expected result. please don't expect others to create it for you. you'll get help if you do that.
    1. Click on the * Add Reputation if you think this helped you
    2. Mark your thread as SOLVED when question is resolved

    Modytrane

  3. #3
    Registered User
    Join Date
    01-10-2018
    Location
    Ger
    MS-Off Ver
    365
    Posts
    11

    Re: How do I copy cells and remove blank?

    It is all in one Excel-data file. I don't know what you mean. Do you have a link to a tutorial what I have to do? I can make Buttons and I know how to copy normal cells, but not how to put them in the spot I want them and how not to copy blanks.

  4. #4
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,563

    Re: How do I copy cells and remove blank?

    What modytrane is requesting is that you upload a sample workbook showing what you want, not just a picture. We can't experiment with pictures and would therefore have to type up sample data to work with. The results will need to be manually placed in the sample so that we can attempt to automate those results with either formulas or code. To upload a sample workbook click on the GO ADVANCED button below the Quick Reply window and then scroll down to Manage Attachments to open the upload window.
    Let us know if you have any questions.
    Consider taking the time to add to the reputation of everybody that has taken the time to respond to your query.

  5. #5
    Registered User
    Join Date
    01-10-2018
    Location
    Ger
    MS-Off Ver
    365
    Posts
    11

    Re: How do I copy cells and remove blank?

    Here is a sample with explaining on every side: https://files.fm/u/8b4qrzeh

  6. #6
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,563

    Re: How do I copy cells and remove blank?

    I know that you are looking for a VBA solution, however since this has not received many responses here is an example of how this might be done using formulas.
    1) On Tabelle 1 the recipes are put into records which makes it easier to access the data. Column F, which was not in the original data, is populated using: =IF(ISTEXT(G2),G2,F1)
    2) On Tabelle 2 data validation is applied to cell E1 which takes the place of the buttons on Tabelle 1 and which references the list in column N.
    3) The array entered formula* which populates column A is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    4) On Tabelle 3 the array entered formula* that populates columns A and B is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    *Array entered formulas are confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer.
    In the future please upload files directly to this site. (directions in post #4)
    Let us know if you have any questions.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    01-10-2018
    Location
    Ger
    MS-Off Ver
    365
    Posts
    11

    Re: How do I copy cells and remove blank?

    Thank you very much. But I have 1 problem:

    I want to work in Tabelle2 "Recipe (all ingredients)" that is where I change the % in the cells. But when i write in it for example 20 % for B the whole thing doesn't work anymore, because I overwrote the code.


    Can you explain me why it is =IF(ISTEXT(G2),G2,F1) and not =IF(ISTEXT(G2),G2,F2)? I don't understand that over the corner thing.
    Last edited by Bifi85; 01-20-2018 at 06:45 AM.

  8. #8
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,563

    Re: How do I copy cells and remove blank?

    I can see that when you overwrite cell A4 on Tabelle2 it changes the other values, however without knowing what you would expect the other values to be I can't offer much in the way of help. If you change A4 to 20% what do you expect to see in cells B3, B4 and B5? An explanation as to why you would expect to see those values would also be helpful.
    The formula is set up so that if there is text in the adjacent cell, in column G, it will copy that text, otherwise it will copy the text from the cell above, in column F. I hope that makes sense.
    I don't understand to what "over the corner" is referring?

  9. #9
    Registered User
    Join Date
    01-10-2018
    Location
    Ger
    MS-Off Ver
    365
    Posts
    11

    Re: How do I copy cells and remove blank?

    Quote Originally Posted by JeteMc View Post
    I can see that when you overwrite cell A4 on Tabelle2 it changes the other values, however without knowing what you would expect the other values to be I can't offer much in the way of help. If you change A4 to 20% what do you expect to see in cells B3, B4 and B5? An explanation as to why you would expect to see those values would also be helpful.
    The formula is set up so that if there is text in the adjacent cell, in column G, it will copy that text, otherwise it will copy the text from the cell above, in column F. I hope that makes sense.
    I don't understand to what "over the corner" is referring?
    Everything you did is very good. Thank you.

    I use baker's percentage all ingredients are compared to 100% flour.

    Maybe the "Data Validation" aka the list where i switch between "alpha" and "beta" should always copy the code into the cells, so they work every time when I want to go back to the original recipe.

    The only thing beside THAT is, that I use some ingredients sometimes in more detailed form. For example when I need 50% water but the preparation says half cold water the other half warm water. So I don't need the 50% water in Tabelle3 but 25% warm water and 25% cold water. But I can mark the cell my myself, when I know how.

    The file should be now clearer. I put it in:
    Attached Files Attached Files

  10. #10
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,563

    Re: How do I copy cells and remove blank?

    As to the "switch between "alpha" and "beta"...[so that they]... go back to the original recipe". That will probably take VBA or possibly a template, I have asked some of the contributors from the VBA to take a look.
    As to the more detailed form, I feel the easiest (perhaps only) way to accomplish that is to add the details to the "All Ingredients" list, so that for example instead of water you would have hot water and cold water. I know if will make the list longer, however there are 1,048,576, and possibly more in the 365 version, rows.
    Let us know if you have any questions.

  11. #11
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: How do I copy cells and remove blank?

    See if you can live with this.
    Changing datavalidation triggers code.
    Attached Files Attached Files
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  12. #12
    Registered User
    Join Date
    01-10-2018
    Location
    Ger
    MS-Off Ver
    365
    Posts
    11

    Re: How do I copy cells and remove blank?

    Quote Originally Posted by bakerman2 View Post
    See if you can live with this.
    Changing datavalidation triggers code.
    Thank you but the problem here is, that sheet 3 never take the values when I add or change some values in sheet 2. - sheet 3 should change the values "live" when I change them in sheet 2. For example 0% Egg -> 4% Egg.

    Sheet 1 has always constant values no matter what, it is like a database.

  13. #13
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: How do I copy cells and remove blank?

    In that case you would need 2 seperate codes.
    1 in sheet1 to send recipy to sheet2 and another one in sheet2 to transfer adapted recipy to sheet3.

  14. #14
    Registered User
    Join Date
    01-10-2018
    Location
    Ger
    MS-Off Ver
    365
    Posts
    11

    Re: How do I copy cells and remove blank?

    Yeah, that would be great.

  15. #15
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: How do I copy cells and remove blank?

    Changing validation changes values on Tabelle2. Code redirects to Tabelle2.
    After making changes (or not) pushing button transfers values to Tabelle3. Code redirects to Tabelle3.
    Attached Files Attached Files

  16. #16
    Registered User
    Join Date
    01-10-2018
    Location
    Ger
    MS-Off Ver
    365
    Posts
    11

    Re: How do I copy cells and remove blank?

    I don't get it right.
    In the picture is what I want to do and the file is below.
    Attached Images Attached Images
    Attached Files Attached Files

  17. #17
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,563

    Re: How do I copy cells and remove blank?

    Perhaps use the following array entered formula* to populate table 4 as in:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    1) Select cell H21,
    2) Paste the formula into the formula bar,
    3) Simultaneously press the Ctrl, Shift and Enter keys,
    4) Double click the fill handle to copy down to H31
    5) While the range H21:H31 is still selected drag the fill handle of over to I31.
    Let us know if you have any questions.

  18. #18
    Registered User
    Join Date
    01-10-2018
    Location
    Ger
    MS-Off Ver
    365
    Posts
    11

    Re: How do I copy cells and remove blank?

    Quote Originally Posted by JeteMc View Post
    Perhaps use the following array entered formula* to populate table 4 as in:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    1) Select cell H21,
    2) Paste the formula into the formula bar,
    3) Simultaneously press the Ctrl, Shift and Enter keys,
    4) Double click the fill handle to copy down to H31
    5) While the range H21:H31 is still selected drag the fill handle of over to I31.
    Let us know if you have any questions.
    It does not work for me.
    I can't copy the formula. Microsoft Excel ERROR "There's a problem with this formula."
    Ctrl+Shift+Enter never did something for me in my Excel.

  19. #19
    Forum Guru
    Join Date
    08-28-2014
    Location
    USA
    MS-Off Ver
    Excel 2019
    Posts
    17,563

    Re: How do I copy cells and remove blank?

    Here is a copy of the file with the formula applied as described.
    Let us know if you have any questions.
    Attached Files Attached Files

  20. #20
    Registered User
    Join Date
    01-10-2018
    Location
    Ger
    MS-Off Ver
    365
    Posts
    11

    Re: How do I copy cells and remove blank?

    It works thank you. What I have to do that this "easy mode" "=IF(ISTEXT(G7);G7;F6)" works?
    Attached Images Attached Images

+ 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. Replies: 9
    Last Post: 11-23-2016, 12:22 PM
  2. [SOLVED] Cocatenate Range of Cells in a column, remove blank cells, and stack text in a cell
    By paxile2k in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-22-2014, 07:47 PM
  3. Replies: 5
    Last Post: 08-26-2013, 06:26 PM
  4. Remove or hide time when copy is blank
    By debbiesh in forum Excel General
    Replies: 2
    Last Post: 03-07-2011, 02:54 PM
  5. remove blank rows and copy new range
    By twofootgiant in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-27-2010, 09:11 AM
  6. How to remove blank cells from row
    By Spac3Monkey in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-03-2009, 10:29 PM
  7. copy column of data, remove blank cells
    By inky in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-22-2008, 09:06 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