![]() |
Fill empty cells
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 ------------------------------------------------------------------------ Thiem's Profile: http://www.excelforum.com/member.php...o&userid=27474 View this thread: http://www.excelforum.com/showthread...hreadid=499318 |
Fill empty cells
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 -- HTHs Martin "Thiem" wrote: 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 ------------------------------------------------------------------------ Thiem's Profile: http://www.excelforum.com/member.php...o&userid=27474 View this thread: http://www.excelforum.com/showthread...hreadid=499318 |
All times are GMT +1. The time now is 02:19 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com