PDA

View Full Version : Copying text from cells to empty cells.



mprija
04-05-2006, 11:55 PM
I have a table of air ticket prices for different destinations. For example JFK-AMS. Problem is that cell with departure airport is merged so actually JFK is written just in first cell. I need macro which would be able to unmerge cells in collum A (1st STEP) and then copy JFK to other 2 empty cells till next airport, in this case till IAD. (2nd STEP), same it should do with all other airports in COLLUM A. In this example there are only 3 SEASONS but there can be more. All this changes should be made in original table, in this example I just copy and paste table 2 times so it is possible to see what needs to be done. If anybody has any idea how to solve it I would be grateful. Thanks.

jindon
04-06-2006, 12:29 AM
Hi
try


Sub test()
With Sheets("Main")
With .Range("b2", .Range("b" & Rows.Count).End(xlUp)).Offset(, -1)
.UnMerge
On Error Resume Next
.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = _
"=r[-1]c"
.Value = .Value
End With
End With
End Sub

mprija
04-06-2006, 06:03 AM
Thanks a lot jindon, your code works perfectly.