+ Reply to Thread
Results 1 to 44 of 44

With code Get Selected Data from one sheet to another

  1. #1
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    With code Get Selected Data from one sheet to another

    Hello experts,
    Refering the code shared by sintek, I am trying to get data from one sheet to a newly created sheet. I have been able to get selected data of all the columns but they are not in the required order. Maybe I missed something which selects a column from one sheet and posts in the wanted column. Also, I need to fill data with values in a few columns as mentioned in the expected sheet. Once again, I need your expertise to get me the expected result and most important of all I request to write the comments. Removed the links from the workbook and attached once again with the expected result.
    Thank you in advance.
    Attached Files Attached Files
    Last edited by RAJESH SHAH; 04-28-2023 at 05:32 AM. Reason: #Solved by beyond excel & Sintek
    "There is nothing called problem, it's just absence of an idea to find*solution."
    ?I have not failed. I?ve just found 10,000 ways that won?t work.?
    ?Thomas Edison

  2. #2
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: With code Get Selected Data from one sheet to another

    Hello RAJESH SHAH
    Let's see if I understand: what we see on the 'Step2 Expected' sheet should go on the 'Step2' sheet instead of what Button 1 is creating on that sheet: Is that so?...
    You are always very welcome if you add reputation by clicking the * (bottom left) of each message that has helped you.

  3. #3
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    Yes. The code will first delete the step2 sheet and then recreates it with the result. Please refer the replaced attachment. The Step2 Expected sheet is just for referring how the result will be.
    Last edited by RAJESH SHAH; 04-27-2023 at 10:19 PM.

  4. #4
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: With code Get Selected Data from one sheet to another

    Ok. Try with:
    Attached Files Attached Files
    Last edited by beyond Excel; 04-28-2023 at 12:27 AM.

  5. #5
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    beyond excel. Thanks man. It is what I expected except for 2 things. The last column is a formula and I want 18 instead of 18%. And how do I remove the table design and get the data normal. As the next step will select the table from this sheet, I hope the table doesn't affect it.

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: With code Get Selected Data from one sheet to another

    Please Login or Register  to view this content.
    Last edited by sintek; 04-28-2023 at 04:05 AM. Reason: changed formatting Column code
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  7. #7
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    Thank you sintek. It is perfect man. I still have many lines to understand to try and write the code like you do. When exactly is colarray used to Store the required columns of source sheet and why have you not used that in this code.?

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: With code Get Selected Data from one sheet to another

    This just stores the column numbers in a variable...To be used later
    Please Login or Register  to view this content.
    I just bypassed that...No specific reason..either or...
    Please Login or Register  to view this content.
    I still have many lines to understand
    Only thing above which could be confusing is the Evaluate Functions...i am merely passing the values immediately by evaluating the formulas...
    Last edited by sintek; 04-28-2023 at 04:13 AM.

  9. #9
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    Ok. Array(1, 8, 16, 9, 10, 11, 12, 14, 1, 1, 1, 8, 13)). I am beginning to understand a bit now. Number order as per display in destination sheet not necessarily ascending order.
    I have edited this one line but please edit again to get the round to 2 decimals.
    Please Login or Register  to view this content.

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: With code Get Selected Data from one sheet to another

    Number order as per display in destination sheet not necessarily ascending order.
    Just merely extracting those columns from Q4 sheet to populate order of Step 1 sheet...You will notice some dummy columns used...
    2 decimals is displayed...

  11. #11
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    Quote Originally Posted by sintek View Post
    This just stores the column numbers in a variable...To be used later
    Please Login or Register  to view this content.
    I just bypassed that...No specific reason..either or...
    Please Login or Register  to view this content.

    Only thing above which could be confusing is the Evaluate Functions...i am merely passing the values immediately by evaluating the formulas...
    Yes. I am comparing that kind of formulas with your evaluate function in different modules, but if a new function is required I will let you know. Like the one to fill the column with a particular value was new and in this case how you wrote that line which will be useful in future.
    Please Login or Register  to view this content.

  12. #12
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: With code Get Selected Data from one sheet to another

    Glad to have helped...tx for rep +
    Happy coding...

  13. #13
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: With code Get Selected Data from one sheet to another

    Quote Originally Posted by RAJESH SHAH View Post
    beyond excel. Thanks man. It is what I expected except for 2 things. The last column is a formula and I want 18 instead of 18%. And how do I remove the table design and get the data normal. As the next step will select the table from this sheet, I hope the table doesn't affect it.
    That's very simple:

    a) Instead of:
    Please Login or Register  to view this content.
    uses:
    Please Login or Register  to view this content.
    b) Remove the line:
    Please Login or Register  to view this content.
    c) And add as last line:
    Please Login or Register  to view this content.
    Last edited by beyond Excel; 04-28-2023 at 08:35 AM.

  14. #14
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    Thanks for the update beyond excel.

  15. #15
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    Sintek, Can you please explain this line.? I am using this type of lines regularly and need to understand. ? What is T in (VLOOKUP(T(I...?
    Please Login or Register  to view this content.
    I am trying to edit it with the below formula but I am not getting the expected result.
    =VLOOKUP(B2,'State Code'!$C$3:$H$39,6,0)
    Please Login or Register  to view this content.
    Last edited by RAJESH SHAH; 04-28-2023 at 09:04 AM.

  16. #16
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    This is the image of the sheet where I got all the results correct except column P. The formula is visible in the display.
    Attachment 827420

  17. #17
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: With code Get Selected Data from one sheet to another

    Attachment is invalid...
    What is T
    Refers Text

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    With reference to this thread and sample data...Your output only has 13 columns...What are you wanting for Col 16...What is currently in Col 16...Has your data layout State Code changed?
    If you are wanting to amend code to make use of in other scenario then you must at least upload said sample file so one can see!

    Come on rajesh...By now you should know this...Not mind readers...
    Last edited by sintek; 04-28-2023 at 09:52 AM.

  18. #18
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    This is a different file I am practicing your code to understand it.
    I got the right result with this but your code I need to really learn.
    Please Login or Register  to view this content.
    If you can tell me what does the T stand for in your formula.

  19. #19
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: With code Get Selected Data from one sheet to another

    This is a different file I am practicing your code to understand it.
    Understood...But like I said...I cannot give you an answer as I don't know what this new data layout looks like...Hence upload a new sample file...
    If you can tell me what does the T stand for in your formula.
    I told you...it represents TEXT if the lookup was for numbers it would be N

  20. #20
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    In the file I shared you can please tell me What is T in (VLOOKUP(T(I...? Maybe then I can edit other codes like you do.

  21. #21
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: With code Get Selected Data from one sheet to another

    Told you twice already...see above...

  22. #22
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    Ok. Thanks man. I will try again tonight and try to understand. gtg now. Have a nice day.

  23. #23
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: With code Get Selected Data from one sheet to another

    Geez...all you have to do is supply the new layout and you will then immediately understand...Like I said...I cannot assume to know what this new file looks like...Cannot help you if you aren't prepared to be more transparent...Have told you this multiple times in other threads...
    See here...

  24. #24
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    I am replacing the codes of most of my old applications which are taking around a minute or more. There are more than 30 modules to edit and most of them have sumifs and vlookup formulas. Each time I have to post a sample workbook for the vlookup code. If I understand then I will be able to change the whole code. You are a great help sintek.
    I will edit the code of each module and wherever I get stuck I will post the same in a new query each time. If that is ok with you. Will post very soon in a new thread.

  25. #25
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: With code Get Selected Data from one sheet to another

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Your formula is looking up the value of B2 in state Col C and getting the result from Col H

    This code below is looking up the value of Col 16 in that state code so if Col 16 is empty there is no lookup available...
    You need to change the code to lookup the offset from Col 16 which will be Col 2 i.e .offset(,-14).address ... I am assuming...
    Not sure what this files setup is...
    Please Login or Register  to view this content.
    Last edited by sintek; 04-28-2023 at 10:57 AM.

  26. #26
    Valued Forum Contributor
    Join Date
    08-08-2022
    Location
    Buenos Aires
    MS-Off Ver
    Excel 2019
    Posts
    1,777

    Re: With code Get Selected Data from one sheet to another

    Quote Originally Posted by RAJESH SHAH View Post
    Thanks for the update beyond excel.
    As always it has been a great pleasure to be able to help you, thanks for the +Rep and do not hesitate to ask any questions you may have.

  27. #27
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    Thanks beyond excel. The pleasure is all mine. Your words inspire me to accept more challenging problems.

  28. #28
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: With code Get Selected Data from one sheet to another

    If I understand your setup then this is what you are wanting...
    Please Login or Register  to view this content.

  29. #29
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    sintek. None of the codes you shared is giving me the expected result. I know it is difficult to write without a sample data. Sorry for keeping you guessing. Here is the file for you to check.
    Attached Files Attached Files

  30. #30
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: With code Get Selected Data from one sheet to another

    sintek. None of the codes you shared is giving me the expected result
    What are you referring to Rajesh..You mentioned Col P and the code in post above gives the correct output???
    Once again just posting files without explanation...
    The codes I supplied for your given files works as they should...Now because you are editing them and trying to use them for other files, now it's my code???
    Last edited by sintek; 04-28-2023 at 12:35 PM.

  31. #31
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    Yes with the code I added. If I replace the P column with your Your below code it s displaying an error.
    Please Login or Register  to view this content.

  32. #32
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: With code Get Selected Data from one sheet to another

    If I replace the P column with your Your below code it s displaying an error.
    What does this mean...replace where what...The file above has no replacement anywhere?

  33. #33
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    To complete the step, I used your one of the codes, edited it and completed it. One formula I was not getting right for column P so I used this code instead and completed it. The file I shared in post #29 is working with this code.
    Please Login or Register  to view this content.

  34. #34
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    Replace that part with your code and check you will see the difference in the result. This one
    Please Login or Register  to view this content.

  35. #35
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: With code Get Selected Data from one sheet to another

    Look at your code above...You changed it from the original I provided...Why add the asteriks
    Last edited by sintek; 04-28-2023 at 12:47 PM.

  36. #36
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    Replace the code I shared in post #33

  37. #37
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: With code Get Selected Data from one sheet to another

    Please Login or Register  to view this content.
    Why you add those...red snippets?

  38. #38
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    sintek. If it is working on your side, please share the file with the code line to autofit.

  39. #39
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: With code Get Selected Data from one sheet to another

    Rajesh...Just REMOVE the red asterisks...They must not be there...don't know why you added them...
    Attached Files Attached Files
    Last edited by sintek; 04-28-2023 at 12:59 PM.

  40. #40
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    Aha.. Now it gave me the correct result. I wonder how the red asterisks got into the line. I just copied and pasted the code. No worries. It is good now. Thanks once again. Sintek
    New query is ready to post. If you are online please have a look. It is very easy but I think I have missed something. It will be solved in no time.

  41. #41
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: With code Get Selected Data from one sheet to another

    You give me headaches Rajesh lol...

  42. #42
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    Sorry man. I really appreciate you trying to make me understand. You can say I am a little slow but passionate to learn and create.

  43. #43
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,239

    Re: With code Get Selected Data from one sheet to another

    You have been doing well...The best way to learn is to create different scenarios and amend code snippets to accommodate...Just need to explain your requirements better...

  44. #44
    Forum Contributor
    Join Date
    11-25-2021
    Location
    INDIA
    MS-Off Ver
    2007
    Posts
    2,147

    Re: With code Get Selected Data from one sheet to another

    Thanks for understanding. I am not just learning to code, but also learning accounts, doing it manually for hours multiple times, see the pattern and work out a plan, start with formulas to get the final result and then write the code and when I get stuck, I take the help from people like you who are always eager to solve💜.

+ 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: 5
    Last Post: 01-08-2023, 02:55 PM
  2. [SOLVED] Code to create a sheet and get selected data from the source sheet
    By RAJESH SHAH in forum Excel Programming / VBA / Macros
    Replies: 35
    Last Post: 11-01-2022, 02:51 AM
  3. Code to delete entire row on sheet when selected in listbox
    By chrismccarthy17 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-02-2016, 12:18 AM
  4. [SOLVED] Enhancement in code - Selected cell will display in new sheet
    By ExcelUser2707 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-23-2014, 03:39 AM
  5. Need Fix for Code To Print Selected Rows On One Sheet
    By elance in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-01-2010, 04:08 PM
  6. VBA code for coping selected data to another sheet based on a criteria
    By BJ5352 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-14-2010, 02:16 AM
  7. [SOLVED] Code for current sheet selected...
    By Brad in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-11-2005, 01: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