Consulting

Results 1 to 4 of 4

Thread: Help! edit multi-cells with conditions. Thank all of you!

  1. #1

    Question Help! edit multi-cells with conditions. Thank all of you!

    Hi, i am student, i need Macro to edit about 3000 quizzies like that ( i edited about ~ 200 quizzes). You can see below, every question contain { content } . I need { } is first variable to define as range to replace content in { } and Answer (A) or Answer (B/D/D) are 2nd variable to define.

    Exp: ​Use can see in ATTACHMENT

    1. We defined Question 1 have { } and next we find in {} contain Answer (B) now Macro will replace (B) One year to
    /=(B) One year. Replace Other choice (A/C/D) to ~(A) Many years ~(C) Until next month ~(D) Today

    Question 1. For how long can this product be enjoyed?
    {
    (A) Many years
    (B) One year
    (C) Until next month
    (D) Today
    ####
    Answer (B)
    More: asd qwe eiquwei oquwoe uqiw ueqio quweo iqwuoe
    }

    ----------After running Macro-->
    Question 1. For how long can this product be enjoyed?
    {
    ~(A) Many years
    /=(B) One year
    ~(C) Until next month
    ~(D) Today
    ####
    Answer (B)
    More: asd qwe eiquwei oquwoe uqiw ueqio quweo iqwuoe
    }

    -------------------------------------------------------------------------------
    2. We defined Question 2 have { } and next we find in {} contain Answer (C) now Macro will replace (C) Four to /=(C) Four

    Question 2. How many different sizes does the product come in?
    {
    (A) A variety
    (B) Two
    (C) Four
    (D) One for each customer
    ####
    Answer (C)
    More: 123 13 1 4 1j4 k1jl4kj 1kl3 1k23jl1
    }

    ------------After running Macro-->
    Question 2. How many different sizes does the product come in?
    {
    ~(A) A variety
    ~(B) Two
    /=(C) Four
    ~(D) One for each customer
    ####
    Answer (C)
    More: 123 13 1 4 1j4 k1jl4kj 1kl3 1k23jl1
    }
    ------------------------------------------------------------------


    Thank all of you!
    Hi, i am student, i need Macro to edit about 3000 quizzies like that ( i edited about ~ 200 quizzes). You can see below, every question contain { content } . I need { } is first variable to define as range to replace content in { } and Answer (A) or Answer (B/D/D) are 2nd variable to define.

    Exp:

    1. We defined Question 1 have { } and next we find in {} contain Answer (B) now Macro will replace (B) One year to
    /=(B) One year. Replace Other choice (A/C/D) to ~(A) Many years ~(C) Until next month ~(D) Today

    Question 1. For how long can this product be enjoyed?
    {
    (A) Many years
    (B) One year
    (C) Until next month
    (D) Today
    ####
    Answer (B)
    More: asd qwe eiquwei oquwoe uqiw ueqio quweo iqwuoe
    }

    ----------After running Macro-->
    Question 1. For how long can this product be enjoyed?
    {
    ~(A) Many years
    /=(B) One year
    ~(C) Until next month
    ~(D) Today
    ####
    Answer (B)
    More: asd qwe eiquwei oquwoe uqiw ueqio quweo iqwuoe
    }

    -------------------------------------------------------------------------------
    2. We defined Question 2 have { } and next we find in {} contain Answer (C) now Macro will replace (C) Four to /=(C) Four

    Question 2. How many different sizes does the product come in?
    {
    (A) A variety
    (B) Two
    (C) Four
    (D) One for each customer
    ####
    Answer (C)
    More: 123 13 1 4 1j4 k1jl4kj 1kl3 1k23jl1
    }

    ------------After running Macro-->
    Question 2. How many different sizes does the product come in?
    {
    ~(A) A variety
    ~(B) Two
    /=(C) Four
    ~(D) One for each customer
    ####
    Answer (C)
    More: 123 13 1 4 1j4 k1jl4kj 1kl3 1k23jl1
    }
    ------------------------------------------------------------------


    Thank all of you!
    Attached Images Attached Images

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Cross-postedin (at least) one other forum, ExcelGuru,

    https://www.excelguru.ca/forums/show...ank-all-of-you!
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    For the future, please post attachments using Go Advanced / Manage Attachments. Images are of little use
    Sub Test()
    rw = Cells(Rows.Count, 1).End(xlUp).Row
    Do
    Set cel = Columns(1).Cells.Find("Answer (", lookat:=xlPart, after:=Cells(rw, 1), searchdirection:=xlPrevious)
    If cel.Row > rw Then Exit Sub
    ans = Mid(cel, 9, 1)
    Set Rng = cel.Offset(-5).Resize(4)
    For Each c In Rng
        If InStr(1, c, "(" & ans & ")") Then
            c.Value = "/=" & c.Value
        Else
            c.Value = "~" & c.Value
        End If
        rw = cel.Row - 1
    Next
    Loop Until cel = ""
    End Sub
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  4. #4

    Wink

    For Xld: I am so sorry, i need fast end my work.

    For Mdmackillop: It's worked for me, so awesome!

    Thank all of you from bottom of my heart (Y) !

    Regards

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •