View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
al al is offline
external usenet poster
 
Posts: 363
Default Please, help with concatenation

thanks a million, I will try it.
Al

"Dave Peterson" wrote:

One way:

Option Explicit
Sub testme()

Dim LastRow As Long
Dim FirstRow As Long
Dim iRow As Long
Dim wks As Worksheet

Set wks = Worksheets("sheet1")

With wks
FirstRow = 2
LastRow = .Cells(.Rows.Count, "B").End(xlUp).Row

For iRow = LastRow To FirstRow + 1 Step -1
If .Cells(iRow, "A").Value = "" Then
.Cells(iRow - 1, "B").Value _
= .Cells(iRow - 1, "B").Value & .Cells(iRow, "B").Value
.Rows(iRow).Delete
End If
Next iRow
End With

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

But I think you may have a problem.

You'd probably want a space between "hole" and "from", but not between "-46" and
"00 ft".

This line did not add a space:
.Cells(iRow - 1, "B").Value _
= .Cells(iRow - 1, "B").Value & .Cells(iRow, "B").Value

If you want a space, change it to:
.Cells(iRow - 1, "B").Value _
= .Cells(iRow - 1, "B").Value & " " & .Cells(iRow, "B").Value

I think either way, you'll have some fixin' to do.


Al wrote:

I have an excel spread sheet with data scanned from an pdf file. the scanned
data looks as follows:

Column A Column B
duration Comments
Row 1 1.5 Drill 8.5" hole
Row 2 from 4500'-46
Row 3 00 ft.

I am having to cut the data from Row 2, and 3 to tack it at the end of row
1. you can imagine that I have to do this for many files and for thousands of
rows. Is there a macro that can help me. I am novice to Excel macros, I need
something that can make this task easy, like highlighting cells 1,2,3 and
click a button to concatenate them the right way(in row 1B). Concatenate
Formula requires me to do as much work, since I have to change the cells
address.
Thank you
Al


--

Dave Peterson