+ Reply to Thread
Results 1 to 16 of 16

Change a number and have the row order change

  1. #1
    Registered User
    Join Date
    05-16-2019
    Location
    Tampa, Florida
    MS-Off Ver
    MS Office 365
    Posts
    46

    Change a number and have the row order change

    I have a CSV Excel file with quiz questions in it.
    The format is Question?;Ans1;Ans2;Ans3;Ans4;CorrectAns;Remediation.
    The actual data looks like this:
    What color is the sky on a sunny cloudless day?; Blue, Green, Chartreuse, Orange, 1, On most sunny, cloudless days the sky is blue.
    What animals swim in the sea?; Fish, Birds, Snakes, Chipmunks, 1, Fish commonly swim in the sea.
    Generally speaking, how many tires are on a car? 4 tires, 2 tires, 3 tires, 1 tire, 1, Generally speaking, most cars traveling the nations roads have four tires plus one in the trunk as a spare.
    The trouble with this is that all the correct answers have been generated as 1.
    How can I change the number in the "CorrectAns" column and have the correct answer's postion change in the spreadsheet. In other words if I change the 1 to a 2, that means that the correct answer must move to the "Ans2" column and what was in the "Ans2 column must more to the "Ans1" column. Is there a way to do this?

  2. #2
    Valued Forum Contributor
    Join Date
    02-06-2014
    Location
    N/A
    MS-Off Ver
    N/A
    Posts
    373

    Re: Change a number and have the row order change

    Would you be able to upload an example workbook, it will help me help you. Thank you!

  3. #3
    Valued Forum Contributor
    Join Date
    11-27-2011
    Location
    usa
    MS-Off Ver
    Excel 2007, Excel 365
    Posts
    495

    Re: Change a number and have the row order change

    I would agree that a small sample file is required because the 3 lines that you provided are not consistent with each other.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,691

    Re: Change a number and have the row order change

    Here's a possible 365 solution.

    With your data in A2 onwards, in B2 copied down:

    =LET(t,TEXTBEFORE(A2,"?")&"?",v,VSTACK(IF(G2=4,{4,1,2,3},IF(G2=3,{3,1,2,4},IF(G2=2,{2,1,3,4},{1,2,3,4}))),TEXTSPLIT(TEXTBEFORE(TEXTAFTER(SUBSTITUTE(A2,";",""),"?"),", ",4),",")),HSTACK(t,INDEX(SORTBY(v,INDEX(v,1),1),2)))

    In column G type the position you want the answer to be in.

    In H2 copied down:

    =TEXTAFTER(A2,"1, ")

    Column A could then be hidden, or on a different sheet (then change the formulae above to refer to that sheet, which I have done in the attached).
    Attached Files Attached Files
    Last edited by AliGW; 07-31-2023 at 02:03 AM. Reason: Workbook updated.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  5. #5
    Registered User
    Join Date
    05-16-2019
    Location
    Tampa, Florida
    MS-Off Ver
    MS Office 365
    Posts
    46

    Re: Change a number and have the row order change

    How do I attach a spreadsheet file?

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,691

    Re: Change a number and have the row order change

    Did you try my suggestion?

    There are instructions at the top of the page explaining how to attach your sample workbook (yellow banner: HOW TO ATTACH YOUR SAMPLE WORKBOOK). Screenshots are of little practical use as we cannot manipulate them.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, worked examples where required, relevant cells highlighted and a few explanatory notes.

  7. #7
    Registered User
    Join Date
    05-16-2019
    Location
    Tampa, Florida
    MS-Off Ver
    MS Office 365
    Posts
    46

    Re: Change a number and have the row order change

    sample quiz.xlsx

    Sorry, yes, I messed up my initial post. I have attached a sample spreadsheet to illustrate what I'm asking. Thanks for your patience.
    Bottom line, the tool that I use for quiz questions creates a preponderance of 1s as the correct answer and I can't have that.
    Thanks again.

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,691

    Re: Change a number and have the row order change

    Did you try my solution, though? Did it work or not?

  9. #9
    Registered User
    Join Date
    05-16-2019
    Location
    Tampa, Florida
    MS-Off Ver
    MS Office 365
    Posts
    46

    Re: Change a number and have the row order change

    Hi Ali,
    I could not get your example to work for me but I think that it was because of the errant information that I put out initially.
    Thank you though.

  10. #10
    Registered User
    Join Date
    05-16-2019
    Location
    Tampa, Florida
    MS-Off Ver
    MS Office 365
    Posts
    46

    Change a number and have the row order change

    I attached a spreadsheet with quiz questions in it. Column D is the Question and columns E through H hold the possible answers. Column I shows the correct answer for that particular question. Therefore, if the CorrectAns column is 3 then the correct answer is in the Ans3 column. If the CorrectAns column is 1 then the correct answer is in the Ans1 column. I want to randomize better the numbers in the CorrectAns column. Many times that column up with too many 1's, not enough 2's, etc. HOWEVER, If I change a number in the CorrectAns column then the physical location of the correct answer must change.

    For example, if I change cell I2 to a 2, then the correct answer must move from G2 to F2 and an incorrect answer must them move into cell G2. Is there any way to accomplish this?
    Attached Files Attached Files

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,691

    Re: Change a number and have the row order change

    You cannot move data in a workbook without VBA. If you want a formula solution, there will need to be helper columns - is this OK?

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,691

    Re: Change a number and have the row order change

    Simple formula solution with helper columns (copied from the main columns).

    Uses: =INDEX(M2:P2,K2)

    and: =MATCH(L2,E2:H2,0)
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    05-16-2019
    Location
    Tampa, Florida
    MS-Off Ver
    MS Office 365
    Posts
    46

    Re: Change a number and have the row order change

    Yes, certainly, helper columns would be OK. And thanks for moving my earlier post. I realize that it was similar to my original post but I took more care in presenting the data and thought that it merited a new post. Won't make the same mistake again.

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,691

    Re: Change a number and have the row order change

    That's OK - I can understand your dilemma, but it is the same query essentially.

    Look at post #12.

  15. #15
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,691

    Re: Change a number and have the row order change

    Does this work for you? Any questions?

    Thanks for the rep.

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

  16. #16
    Forum Guru HansDouwe's Avatar
    Join Date
    06-21-2022
    Location
    Nederland
    MS-Off Ver
    365 V2403 (Build 17330.20000)
    Posts
    6,466

    Re: Change a number and have the row order change

    Here is another solution:

    Please enter the questions, the correct answer and the wrong aswers in an help-table and try in E2 and copy down:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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. Processing order of key board event calling Worksheet.Change and Worksheet.Change
    By datawrangler168 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-15-2023, 12:03 AM
  2. [SOLVED] Formula for making numbers in random order change to ascending order
    By bansche123 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-25-2021, 09:18 AM
  3. [SOLVED] Change all matching Value based on number change in Column Excel 2007
    By Excelnoub in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 02-20-2014, 11:40 AM
  4. Add numbers to column based on order number change
    By fpmsi in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-11-2013, 11:48 AM
  5. Sum charge amount every time the code and the order number change
    By children in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-19-2013, 08:49 AM
  6. [SOLVED] VBA to detect change in order number, then add a value to each 1st line of that order
    By Marijke in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-04-2013, 09:19 AM
  7. [SOLVED] can excel change number 1532 to 1235 running order
    By Bluesy69 in forum Excel General
    Replies: 11
    Last Post: 05-05-2005, 03:51 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