Thread: Fill in Blanks
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
ker_01 ker_01 is offline
external usenet poster
 
Posts: 395
Default Fill in Blanks

Macro solution:

'A is a column that will always have data in your data set,
'B is the column that has blanks to be filled
Sub fill_blanks()
For i = 1 to 10000 '<-increase to be larger than your max number of rows
if Sheet1.range("A" & i).value="" then exit sub
If Sheet1.range("B" & i).value <"" then
tempval = Sheet1.range("B" & i).value
else
Sheet1.range("B" & i).value = tempval
endif
Next
end sub

However, and easier solution: insert a new column, and starting in row 2 (B2
in your example)
=if(A2<"",A2,,A1)

copy it all the way down, then copy/paste special/values over the original
column... then delete the (temporary) column that has this formula in it.

HTH,
Keith

"Steve Stad" wrote:

I would like to fill in blank cells in one Column with the value of the
nonblank cell above the blank cells. e.g., automatically fillin A2 and A3
with 'orange' and fill in A5, and A6 with 'apple'. Can you suggest macro
steps?
A
1 orange
2
3
4 apple
5
6
7