SIMPLE VBA CODING REQUIRED

nburaq

Board Regular
Joined
Apr 2, 2021
Messages
220
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi Gents,
The database program I work with generally converts the data with empty spaces and it is very annoying to arrange it every time to be able to work with excel. Is it possible to fill empty cells with the screenshot below: PS: I filled one by manually by red color as an example. If there is title, item or group belongs to an order it gives empty cells and I have to fill it manually and between every item there are three empty rows if there is data belong to order. Thanks for the comments and help!
Screenshot 2021-04-22 210826.png
 
Maybe this?

Code:
Sub FillIn()
Dim lr As Long, i As Long
lr = WorksheetFunction.Max(Cells(Rows.Count, "E").End(xlUp).Row, Cells(Rows.Count, "D").End(xlUp).Row)

For i = 1 To lr
 If IsEmpty(Cells(i, 1)) And Not IsEmpty(Cells(i, 5)) Then
 Cells(i, 1) = Cells(i - 2, 1)
 Cells(i, 2) = Cells(i - 2, 2)
 Cells(i, 3) = Cells(i - 2, 3)
 Cells(i, 4) = Cells(i - 2, 4)
 ElseIf IsEmpty(Cells(i, 1)) And Not IsEmpty(Cells(i, 4)) Then
 Cells(i, 1) = Cells(i - 2, 1)
 Cells(i, 2) = Cells(i - 2, 2)
 Cells(i, 3) = Cells(i - 2, 3)
 Cells(i, 5) = Cells(i - 2, 5)
 End If
Next i
End Sub
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Forum statistics

Threads
1,214,833
Messages
6,121,857
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top