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
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
So, is row 5 missing ONLY A5 and then you want the "2345" filled in? Same with row 7.
OR, does the 2345 exist in A5 and you want the other three columns (B, C, and D) filled when there's a match?
 
Upvote 0
So, is row 5 missing ONLY A5 and then you want the "2345" filled in? Same with row 7.
OR, does the 2345 exist in A5 and you want the other three columns (B, C, and D) filled when there's a match?
2345 exists in row3 with other values next to each other and until row 11 then it starts with new item. i need to fill column A5/B5/C5/D5 by looking at column E whether there is a value ( in this case for 2345 "BAD")
 
Upvote 0
I'm still a bit confused. Does all of row 5 get filled in because "BAD" is in E5 and row 5 is 2 below row 3 that has a "BAD" in E?

If so, by that logic, row 7 is filled in the same.

Then, what gets filled in row 13? Does the GOOD match the "GOOD" in row 11 so the KLM, etc. info gets filled in?
 
Upvote 0
If this is the original:

Book3
ABCDE
1OrderTitleItemGroupDesc
21234ABC1AGOOD
32345XYZ10BBAD
4
5BAD
6
7BAD
8
9
10
113210KLM12CGOOD
12
13GOOD
14
15
16
174567CDE9KBAD
18
19BAD
Sheet1


Is this what you want:

Book3
ABCDE
1OrderTitleItemGroupDesc
21234ABC1AGOOD
32345XYZ10BBAD
4
52345XYZ10BBAD
6
72345XYZ10BBAD
8
9
10
113210KLM12CGOOD
12
133210KLM12CGOOD
14
15
16
174567CDE9KBAD
18
194567CDE9KBAD
Sheet1
 
Upvote 0
If this is the original:

Book3
ABCDE
1OrderTitleItemGroupDesc
21234ABC1AGOOD
32345XYZ10BBAD
4
5BAD
6
7BAD
8
9
10
113210KLM12CGOOD
12
13GOOD
14
15
16
174567CDE9KBAD
18
19BAD
Sheet1


Is this what you want:

Book3
ABCDE
1OrderTitleItemGroupDesc
21234ABC1AGOOD
32345XYZ10BBAD
4
52345XYZ10BBAD
6
72345XYZ10BBAD
8
9
10
113210KLM12CGOOD
12
133210KLM12CGOOD
14
15
16
174567CDE9KBAD
18
194567CDE9KBAD
Sheet1
You are magician! Yes even I cant explain very well this is what I really want ! Then I will remove the empty rows with classic find empty cells and delete rows :) then voila a clean data to be used
 
Upvote 0
I used this:

Code:
Sub FillIn()
Dim lr As Long, i As Long, w As Long
lr = Cells(Rows.Count, "E").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)
 Else
 End If
Next i
End Sub
 
Upvote 0
I used this:

Code:
Sub FillIn()
Dim lr As Long, i As Long, w As Long
lr = Cells(Rows.Count, "E").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)
Else
End If
Next i
End Sub[/
[/QUOTE]
It gives an compile error: expected end of statement
 
Upvote 0
Do you have that stuff at the end? Re-copy and install this:

Code:
Sub FillIn()
Dim lr As Long, i As Long
lr = Cells(Rows.Count, "E").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)
 Else
 End If
Next i
End Sub
 
Upvote 0
Do you have that stuff at the end? Re-copy and install this:

Code:
Sub FillIn()
Dim lr As Long, i As Long
lr = Cells(Rows.Count, "E").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)
Else
End If
Next i
End Sub
Sorry it was my bad because I think I found why it gave error; There are empty cells under column "Desc" despite that row has "order " in this case either I have to fill those cells by myself as "NA" or could you implement this to your code ? Thanks again
 
Upvote 0

Forum statistics

Threads
1,215,050
Messages
6,122,868
Members
449,097
Latest member
dbomb1414

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