View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Jason Hall Jason Hall is offline
external usenet poster
 
Posts: 14
Default backfill cells with macros

This worked but, it worked too well. In otherwords, this is what happen

A B C D E
1 x x x O O
2 x x O x T

On line 1 the code worked great, however, on line 2 the code seen the blank
on D2 and replaced everything on line 2 with E2 "T" over writing C2 "O" and
populating A2 and B2 with "T" instead of "O"


"JLGWhiz" wrote:

This worked on a small test area:

Sub bckfl()
Dim x, y As Range
lr = Cells(Rows.Count, 1).End(xlUp).Row
i = 2
For Each y In Range("A2:A" & lr)
lc = Cells(i, Columns.Count).End(xlToLeft).Column
For Each x In Range(Cells(i, 1), Cells(i, lc))
If x = "" And x.Offset(0, 1) = "" Then
Range("A" & i, x.End(xlToRight).Offset(0, -1)) = x.End(xlToRight).Value
ElseIf x = "" And x.Offset(0, 1) < "" Then
x.Offset(0, 0) = x.Offset(0, 1).Value
End If

Next x
i = i + 1
Next y
End Sub

Might need some tweaking for your application.

"Jason Hall" wrote:

I am trying to figure out a way to backfill blank cells in Excel on the same
row. For example:

column A B C D

1 x x x o
2 x x o o
3 x x x o

In row 1 I want the information in cell 1D populate the blank cells in
column 1A,1B, and 1C
In row 2 I want the information in cell 2C to poplulate the blank cells in
column 2A and 2B

Ideally, I want Excel to realize that there are blank cells in a row and
fill those blank cells with the first information it finds on that row.