View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
XP XP is offline
external usenet poster
 
Posts: 389
Default replace apostrophe with values above

One way:

If the characters in the cells are truly two single quotes, try this:

Dim lX As Long
Dim rCell As Range
For Each rCell In ActiveSheet.UsedRange.Columns(1).Rows
If rCell.FormulaR1C1 = "''" Then
rCell.Value = rCell.Offset(-1, 0).Value
rCell.Offset(0, 1).Value = rCell.Offset(-1, 1).Value
End If
Next rCell

If the characters are actually double quotes, try this:

Dim lX As Long
Dim rCell As Range
For Each rCell In ActiveSheet.UsedRange.Columns(1).Rows
'If rCell.FormulaR1C1 = """" Then MsgBox "got it " & rCell.Address
If rCell.FormulaR1C1 = "''" Then
rCell.Value = rCell.Offset(-1, 0).Value
rCell.Offset(0, 1).Value = rCell.Offset(-1, 1).Value
End If
Next rCell

HTH

"Koen" wrote:

Hi, I'm looking for a solution for the following problem:
I have data in more or less the following form:

A B
1/1/08 Alex
" "
" "
13/1/08 Sarah
" "
" "

The apostrophes meaning that this cell has the same entry as the one above

So what I want to have is my data in the following form:

A B
1/1/08 Alex
1/1/08 Alex
1/1/08 Alex
13/1/08 Sarah
13/1/08 Sarah
13/1/08 Sarah


I used the code like in the following thread:

http://www.microsoft.com/communities...=en-us&m=1&p=1

It works fine for all symboles except for the apostrophe, because it has
some sort of function in VBA (don't know, because I cannot program in VBA)

Can anyone help me, or do I have to use a different symbol?

Thanks in advance,

Koen