Add missing entries in column

gavinj2006

New Member
Joined
Jul 28, 2015
Messages
11
Office Version
  1. 365
Platform
  1. Windows
I have a sheet of order exports to be reimported to an excommerce system, the new system requires that for both lines of the order (order and despatch) have an email address but the export has some (many) missing.

I need to select the column and have Excel add the missing emails where appropriate.

The example containes an illustration of the sheet, the 2 detail lines are the order and despatch details and the empty rows below are details of the specific products ordered.

In the example, cells B8 and B30 needs to have the email address from cell B7 and B29, the rest are correct.

Any help would be much appreciated, thanks

Book1
ABC
1infoemail
2detaila@a.com
3detaila@a.com
4
5
6
7detaila@a.com
8detail
9
10
11
12
13
14
15
16detaila@a.com
17detaila@a.com
18
19
20
21
22detaila@a.com
23detaila@a.com
24
25detaila@a.com
26detaila@a.com
27
28
29detaila@a.com
30detail
31
32
33detaila@a.com
34detaila@a.com
35
Sheet1
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
gavin Let's get the ball rolling. Here is my solution to your problem. Now this means you have to know a little about programming or VBA. If you do then fine. If you don't then we can help you work this. We have to start somewhere so let the question and discussion begin.

VBA Code:
Sub Prog1()
Dim CellCnt As Integer

CellCnt = Cells(Rows.Count, "A").End(xlUp).Row

For i = CellCnt To 2 Step -1

If Cells(i, 1) <> "" And Cells(i, 2) = "" Then

Cells(i, 2).FormulaR1C1 = "=r[-1]c2"

End If

Next i

End Sub


23-08-11.xlsm
AB
1infoemail
2detaila@a.com
3detail
4
5
6
7detaila@a.com
8detail
9
10
11
12
13
14
15
16detaila@a.com
17detaila@a.com
18
19
20
21
22detaila@a.com
23detail
24
25detaila@a.com
26detaila@a.com
27
28
29detaila@a.com
30detail
31
32
33detaila@a.com
34detaila@a.com
Data
 
Upvote 0
Solution
That is absolutely perfect, thank you for your help, just saved me days of skimming through spreadsheets!
 
Upvote 0
I also want to congratulate you for keeping your problem simple and using XL2BB. I am able to help when this is the case.
 
Upvote 1
An alternative would be to populate them all at once rather than loop through a row at a time.

VBA Code:
Sub Add_emails()
  With Range("B3:B" & Range("A" & Rows.Count).End(xlUp).Row)
    .SpecialCells(xlBlanks).FormulaR1C1 = "=IF(RC[-1]="""","""",R[-1]C)"
    .Value = .Value
  End With
End Sub

BTW, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 1
I am going to save Peter's solution in my toolbox for future reference. I really like it.
 
Upvote 1
An alternative would be to populate them all at once rather than loop through a row at a time.

VBA Code:
Sub Add_emails()
  With Range("B3:B" & Range("A" & Rows.Count).End(xlUp).Row)
    .SpecialCells(xlBlanks).FormulaR1C1 = "=IF(RC[-1]="""","""",R[-1]C)"
    .Value = .Value
  End With
End Sub

BTW, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
Thanks for that, super slick solution

I updated as suggested :)
 
Upvote 0

Forum statistics

Threads
1,215,139
Messages
6,123,259
Members
449,093
Latest member
Vincent Khandagale

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