Fill empty cells

  • Thread starter Thread starter Thiem
  • Start date Start date
T

Thiem

I am running reports of a DB. Problem is that I have information that is
left blank, if the information in question has multiple entries. For
example:


Store Name Store Group Product


X ABC
H
Blank (X) Blank (ABC)
J
Y ABC
H
Z ABC
H
Blank (Z) Blank (ABC)
J
Blank (Z) Blank (ABC)
I



So the blank cell should have contained the same info as the cell
directly above it. Any help on VBA to achieve this?
 
Thiem,

Try this

Sub insert_data()
' assume headings on row 1 and data starts on row 2
Dim ws As Worksheet
Dim r As Long
Set ws = ActiveSheet
r = 2
Do While (ws.Range("C" & r) <> "")
If ws.Range("A" & r) = "" Then
ws.Range("A" & r) = ws.Range("A" & r - 1)
End If
If ws.Range("B" & r) = "" Then
ws.Range("B" & r) = ws.Range("B" & r - 1)
End If
If r = 65536 Then Exit Do
r = r + 1
Loop
Set ws = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top