Simple Excel operation, help needed

  • Thread starter Thread starter forums
  • Start date Start date
F

forums

Hi there,

I have text strings in column A and corresponding text strings in
column B.

Some text strings in column A are duplicate.

I want for those duplicate text strings that are in column A to have
the same corresponding text strings in column B automatically added.

How can I do that?

Regards,
Alexa
 
Not sure, are you talking about CONCATENATION?..........if so, in C1 put
this and copy down.......

=A1&" "&B1

Vaya con Dios,
Chuck, CABGx3
 
Alexa,

Explain what you mean by "corresponding." You might need to give us a small
sample of your data. Show the before and the after.
 
Alexa,

Like Chuck, I'm not sure either but I read it slightly differently. I
thought that you were saying that there was text in Columns A and B with
duplicates in Column A but not all duplicates in Column A had the text in
Column B. The question then was how to fill in the missing text in Column
B. If so then this code should do the necessary.

Option Explicit
Sub FillIn()

Dim c As Long, s As Long, x As Long, y As Long
Dim LookFor As String, LookTo As String

Application.ScreenUpdating = False

c = Application.CountA(Range("A:A"))
'If there is other data further down in Column A
'restrict the range in A:A

Range("A1:A" & c).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=Range( _
"Z1"), Unique:=True

s = Application.CountA(Range("Z:Z"))
'If there is data in Column Z change the range
'with all the corresponding Z references in the code

For x = 2 To s

LookFor = Cells(x, "Z").Value

For y = 2 To c
If Cells(y, 1).Value = LookFor Then
If Cells(y, 2).Value <> "" Then
LookTo = Cells(y, 2).Value
Exit For
End If
End If
Next y

For y = 2 To c
If Cells(y, 2).Value = "" Then
If Cells(y, 1).Value = LookFor Then
Cells(y, 2).Value = LookTo
End If
End If
Next y

Next x

Range("Z1:Z" & s).Value = ""

Application.ScreenUpdating = True

End Sub

HTH

Sandy
 
Here are the text strings in columns A and B:

Rows Column A Column B

Row 1 string1 stringA
Row 2 string2 stringB
Row 3 string3 stringC
Row 4 string1
Row 5 string4 stringD
Row 6 string3

Rows 4 and 6 doesn't have any data in column B.

I want excel to place stringA in Row4,ColumnB and stringC in
Row6,ColumnB because in previous rows Column A strings have these
strings in Column B..

How can I automate this with Excel?

Regards,
Alexa
 
Hi Sandy,

Can you give exact instructions where I should place this code?

Regards,
Alexa
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top