PDA

View Full Version : [SOLVED:] Help! edit multi-cells with conditions. Thank all of you!



imbaboy95
09-24-2017, 09:00 PM
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!

Bob Phillips
09-24-2017, 10:50 PM
Cross-postedin (at least) one other forum, ExcelGuru,

https://www.excelguru.ca/forums/showthread.php?8423-Help!-edit-multi-cells-with-conditions-Thank-all-of-you!

mdmackillop
09-25-2017, 03:28 AM
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

imbaboy95
09-25-2017, 06:34 AM
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