excel macro rather difficult

  • Thread starter Thread starter Wenom
  • Start date Start date
W

Wenom

I'd like to know if any of you could write a macro for me. This is rather
complicated and I'm not sure if it's possible to do something like that
with a macro.

I will give you an example and try to show what it should do.

The excel file i a set of cells which are in one column.

They look like that:

Q: such that is without people and sad (about aplace)

A: desolate ['desolet]

Q: sepsis (med)

A: infection/gangrene ['gengrin]


As you can see there are empty spaces between them plus they never start
from numbers.

The macro should do the following. I'll put comments in ' '

Q: such that is without people and sad (about aplace)
'the first line starts from Q: but it's longer than 1 word I try to swap,
after swap i see that there's a square bracket i delete the square
brackets and delete what's inside them. After swapping I join the cells
and replace Q: or A: depending on their order with :'
A: desolate ['desolet]

'the text should now look like that'
A: desolate : such that is without people and sad (about aplace)

Q: sepsis (med)
'I see the oval braket i delete it and what's inside. The first part is
one word only then so I don't swap.'
A: infection/gangrene ['gengrin]

'the text looks like that'
Q: sepsis : infection/gangrene

'If both the first and the second part are longer than 1 word ecen after
the deletion of square and oval brackets i skip and continue to the next
pair.

I'd be really greatful for your help.
 
Does it have to be a macro? If A1, A3, A5, ... are the questions and A2, A4,
A6, ... are the answers then write in B1:
=LEFT(OFFSET($A$1,ROW()*2,0),FIND(OFFSET($A$1,ROW()*2,0),"[")-1)&":
"&OFFSET($A$1,ROW()*2-1,0)
and copy down.

HTH,
Bernd
 
Dnia Sun, 12 Sep 2004 11:14:42 +0200, Bernd Plumhoff
Does it have to be a macro? If A1, A3, A5, ... are the questions and A2,
A4,
A6, ... are the answers then write in B1:
=LEFT(OFFSET($A$1,ROW()*2,0),FIND(OFFSET($A$1,ROW()*2,0),"[")-1)&":
"&OFFSET($A$1,ROW()*2-1,0)
and copy down.

It's not that easy. questions and answers must meet the constraints that
i've given above. I tried your code but it doesn't work.
 
=MID(LEFT(OFFSET($A$1,ROW()*2,0),FIND(OFFSET($A$1,ROW()*2,0),"[")-1),3)&":
"&MID(OFFSET($A$1,ROW()*2-1,0),3)

in B1 should work. What was/is your result or whats still missing?

Regards,
Bernd
 
Dnia Sun, 12 Sep 2004 14:13:48 +0200, Bernd Plumhoff
=MID(LEFT(OFFSET($A$1,ROW()*2,0),FIND(OFFSET($A$1,ROW()*2,0),"[")-1),3)&":
"&MID(OFFSET($A$1,ROW()*2-1,0),3)

it says there's a mistake in the formula. $A$1 is in red
 
Back
Top