View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default A macro to fill in the blank cells

Select all your data, only colums A and B

Do edit=goto special
and select Blank Cells

Now all the blank cells should be selected
Now A2 should be the active cell
goto the formula bar and enter
=A1

so the formula would be the filled cell above the activecell (if it isn't
A2, adjust)

and do Ctrl+Enter to finish editing rather than enter

this puts the formula in all the selected cells and fills them in

Now select columns A and B of your data and do Edit=Copy and immediately
Edit=Paste Special and select Values so the formulas are replace with the
value they display.

in code it would be

Sub Fillblanks()
Dim rng As Range, rng1 As Range
Set rng = Intersect(ActiveSheet.UsedRange, _
ActiveSheet.Columns(1).Resize(, 2))
Set rng1 = rng.SpecialCells(xlBlanks)
rng1.Formula = "=" & rng1(0, 1).Address(0, 0)
rng.Formula = rng.Value
End Sub

--
Regards,
Tom Ogilvy




"jer101 " wrote in message
...
I recieve a file every month that requires me to it clean up before I
can us it in a pivot table. One of the things I am required to do is
copy data into blank cells, for example. In the following table I
would be requred to copy into row 2 and 3 what is on row 1 in columns A
and B. Then I would copy what's on row 4 column A and B onto line 5...
and so on. Is there a macro that would do this for me?

Spreadsheet column

A B C
1 Mr. Jones 9483 $3,434
2 $ 524
3 $3,200
4 Ms. Black 1052 $1,255
5 $ 251
6 Mr. Smith 2254 $ 553
7 Ms. James 5855 $ 651
8 $1,221
9 $9,332


---
Message posted from http://www.ExcelForum.com/