Help me automate these tasks between sheets

JohnnyBeGood

New Member
Joined
Mar 29, 2007
Messages
26
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I'm hoping someone will be able to help me automate this task. Currently, I'm doing it manually and its time-consuming. I'm sure there's a better way of doing it, but I don't know.
Attached are sample files. First workbook has two sheets MASTER_LIST and Sheet1 and final_merge is how information needs to be merged. The account is in 000902-000 format, and it needs to be 902
Only accounts appearing on Sheet1 need to be filtered, and the master_list file contains around 10,000 lines. If all fields with numbers are empty ACTION NEEDED needs to be populated.
Also, master_list gets exported weekly, and new information is pulled. Please let me know if more clarification is needed.

Thanks in advance!

master_list.xlsx
ABCDEFGHIJKL
1Customer Numlast_namefirst_nameaddr_care_ofaddr_1citystatezipemailhome_phonebus_phonecell_phone
2-----------------------------------------------------------------------------------------------
33JOHNDOE16619 SE 1ST AVEBIG CITYNY550429105johndoe@mail.com5061231234
41002CHATEAU BUSINESS PARK-FC/ABCD LLC16620 SE 1ST AVEBIG CITYNY55042914550612312355061231254
5147555MIKEWINTERSABC CORP16621 SE 1ST AVEBIG CITYNY550422933
6137545JOHNNYGOOD16622 SE 1ST AVEBIG CITYNY5504291055061231237
7902LUCYDOE16633 SE 1ST AVEBIG CITYNY550429100lucydoe@mail.com; doelucy25@mail2.com
8127555STEVESUMMER123 CORP16656 SE 1ST AVEBIG CITYNY55044910550612312315061231265
MASTER_LIST


master_list.xlsx
ABC
1ACCOUNT NUMBERNAMEADDRESS
2001002-000CHATEAU BUSINESS PAR16620 SE 1ST AVE
329261052
4issue2
5147555-000MIKE WINTERS16621 SE 1ST AVE
634713349
7issue1
8000902-000LUCY DOE16633 SE 1ST AVE
933462540
10issue2
11127555-000STEVE SUMMER16656 SE 1ST AVE
1234409077
13issue1
Sheet1


final_merge.xlsx
ABCDEFGHIJK
1ACCOUNT NUMBERNAMEaddr_care_ofADDRESSEMAILPHONE TO CALLbus_phonePHONE TO TEXTDEVICE IDACTION NEEDEDPROBLEM
23JOHN DOE16619 SE 1ST AVEjohndoe@mail.com506123123429261052issue2
3147555MIKE WINTERSABC CORP16621 SE 1ST AVE34713349No contact, mail letterissue1
4902LUCY DOE16633 SE 1ST AVElucydoe@mail.com; doelucy25@mail2.com33462540No contact, mail letterissue2
5127555STEVE SUMMER123 CORP16656 SE 1ST AVE5061231231506123126534409077issue1
final_merge
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Just to clarify; the 'MASTERLIST' will be different each week, therefore no formatting is required, but rather sheet1 & final merge is where you require automation, correct?
 
Upvote 0
Thanks for the reply!

Correct. Columns in MASTER_LIST will not change only phone numbers and emails will be updated. New lines will be added to the bottom as new customers are added.
Information on Sheet1 will have new information each week that will need to be matched against MASTER_LIST and added to final_merge. Let me know if you need more clarification.
 
Upvote 0
Sheet1 is throwing me a curveball with that "issue" being listed under 'ACCOUNT NUMBER' and their 'Device ID'. Is that just how your system exports data?

Also, does sheet1 contain other columns of data such as Email, Phone to Call, bus_phone, etc.?
 
Upvote 0
Sheet1 comes from a different system, and the data is really "dirty" with a bunch of empty spaces and some other data that is unnecessary. On top of that, where ie. account number, device id, issue1, issue2 appear is not consistent.
The only way I could clean it up is by copying the first 3 columns and doing "Format as table" and then unchecking unnecessary info, which gives me some consistency at the end.
Here is a sample of how it comes before cleaning it up:


RAW Cycle 11 and 31 Endpoint Tampers Report.xls
ABC
1
2
3
4
5
6ACCOUNT NUMBERNAMEADDRESS
7001002-000 CHATEAU BUSINESS PAR16620 SE 1ST AVE
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2429261052
25W
26
2700
28
29
30
31
32COUNTS/FLAG:1: 1/ 2: 0
33
34issue2
35
36
37
38
39
40147555-000 MIKE WINTERS 16621 SE 1ST AVE
Sheet1
 
Upvote 0
Appreciate the secondary screenshot of ‘Sheet1’.

Going off the ‘MASTER_LIST I believe there’s an error with the first and last name columns, so I switched it on my end – the names, not the actual columns, but just alter the formulas if I’m mistaken.

Book1.xlsm
ABCDEFGHIJKL
1Customer Numlast_namefirst_nameaddr_care_ofaddr_1citystatezipemailhome_phonebus_phonecell_phone
2------------------------------------------------------------------------------------------------------------------------------------------------
33DOEJOHN16619 SE 1ST AVEBIG CITYNY550429105johndoe@mail.com5061231234
41002CHATEAU BUSINESS PARK-FIC/ABCD LLC16620 SE 1ST AVEBIG CITYNY5504291455061231235
5147555WINTERSMIKEABC CORP16621 SE 1ST AVEBIG CITYNY550422933
6137545GOODJOHNNY16622 SE 1ST AVEBIG CITYNY55042910550612312375061231254
7902DOELUCY16633 SE 1ST AVEBIG CITYNY550429100lucydoe@mail.acom; doelucy25@mail2.com
8127555SUMMERSTEVE123 CORP16656 SE 1ST AVEBIG CITYNY55044910550612312315061231265
MASTER_LIST


Since you are only using columns A:C I went ahead and inserted a D & E column to help with your ‘final_merge’ The pattern appears to be the 'Device ID' is always second and the 'issue#' is third, so taking this simple cell reference and it being a relative reference should give you what you seek.
Note: you'll still need to sort your data into the first example (sheet1). I attempted to construct a VBA code to help with this, but my knowledge of VBA is still very... novice, and struggled with the 8 digit formatting.

Book1.xlsm
ABCDE
1ACCOUNT NUMBERNAMEADDRESSDEVICE IDPROBLEM
2000003-000JOHN DOE16619 SE 1ST AVE29261052issue2
329261052issue2001002-000
4issue2001002-00034713349
5001002-000CHATEAU BUSINESS PARK-FIC/ABCD LLC16620 SE 1ST AVE34713349issue1
629261052issue2001002-000
7issue2001002-00034713349
8001002-000MIKE WINTERS16621 SE 1ST AVE34713349issue1
934713349issue1000902-000
10issue1000902-00033462540
11000902-000LUCY DOE16633 SE 1ST AVE33462540issue2
1233462540issue2127555-000
13issue2127555-00034409077
14127555-000STEVE SUMMER16656 SE 1ST AVE34409077issue1
1534409077issue10
16issue100
Sheet1
Cell Formulas
RangeFormula
D2:D5D2=A6
E2:E5E2=A7
D6:D16D6=A7
E6:E16E6=A8


I did a string of vlookups to format your ‘final_merge’ sheet. I believe you’re using 2 workbooks, but I made it just another sheet on my end to test it.

Convert your ‘final_merge’ into a table and use the following layout:

Cell Formulas
RangeFormula
A2:A14A2=IF(B2<>0,VALUE(LEFT(Sheet1!A2,6)),"")
B2:B14B2=Sheet1!B2
C2:C14C2=IFERROR(VLOOKUP(A2,MASTER_LIST!A:L,4,FALSE),"")
D2:D14D2=IFERROR(VLOOKUP(A2,MASTER_LIST!A:L,5,FALSE),"")
E2:E14E2=IFERROR(VLOOKUP(A2,MASTER_LIST!A:L,9,FALSE),"")
F2:F14F2=IFERROR(VLOOKUP(A2,MASTER_LIST!A:L,10,FALSE),"")
G2:G14G2=IFERROR(VLOOKUP(A2,MASTER_LIST!A:L,11,FALSE),"")
H2:H14H2=IFERROR(VLOOKUP(A2,MASTER_LIST!A:L,12,FALSE),"")
I2:I14I2=IFERROR(VLOOKUP(B2,Sheet1!B:E,3,FALSE),"")
J2:J14J2=IF(OR(F2>0,G2>0,H2>0),"","No Contact")
K2:K14K2=IFERROR(VLOOKUP(B2,Sheet1!B:E,4,FALSE),"")


After that all you’ll need to do is go into Cell A1 and uncheck ‘Blanks’ and you’ll see all the data you’re after.

Cell Formulas
RangeFormula
A2,A5,A8,A11,A14A2=IF(B2<>0,VALUE(LEFT(Sheet1!A2,6)),"")
B2,B5,B8,B11,B14B2=Sheet1!B2
C2,C5,C8,C11,C14C2=IFERROR(VLOOKUP(A2,MASTER_LIST!A:L,4,FALSE),"")
D2,D5,D8,D11,D14D2=IFERROR(VLOOKUP(A2,MASTER_LIST!A:L,5,FALSE),"")
E2,E5,E8,E11,E14E2=IFERROR(VLOOKUP(A2,MASTER_LIST!A:L,9,FALSE),"")
F2,F5,F8,F11,F14F2=IFERROR(VLOOKUP(A2,MASTER_LIST!A:L,10,FALSE),"")
G2,G5,G8,G11,G14G2=IFERROR(VLOOKUP(A2,MASTER_LIST!A:L,11,FALSE),"")
H2,H5,H8,H11,H14H2=IFERROR(VLOOKUP(A2,MASTER_LIST!A:L,12,FALSE),"")
I2,I5,I8,I11,I14I2=IFERROR(VLOOKUP(B2,Sheet1!B:E,3,FALSE),"")
J2,J5,J8,J11,J14J2=IF(OR(F2>0,G2>0,H2>0),"","No Contact")
K2,K5,K8,K11,K14K2=IFERROR(VLOOKUP(B2,Sheet1!B:E,4,FALSE),"")
 
Upvote 0
Thank you so much for this!
I'm away from the computer now and will try it out and post back results.
 
Upvote 0
Looks like my example had a little typo I overlooked.
On sheet1 I really wanted to make it so you didn't have to manually delete rows and sort it, since there appears to be a pattern from what I'm seeing.

threw together this random bit:
Book1.xlsm
ABCDE
1ACCOUNT NUMBERNAMEADDRESSDEVICE IDPROBLEM
2000003-000JOHN DOE16619 SE 1ST AVE29261052issue2
329261052
4issue2
5001002-000CHATEAU BUSINESS PARK-FIC/ABCD LLC16620 SE 1ST AVE
629261052
7issue2
8
9
10
11
12
13
14
15f
16
17
18
19
20
21
22s
23
24
25
26
27
28
292
30
31
32
33
34
35random
36
37
38
39001002-000MIKE WINTERS16621 SE 1ST AVE
4034713349
41issue1
42000902-000LUCY DOE16633 SE 1ST AVE
4333462540
44issue2
45127555-000STEVE SUMMER16656 SE 1ST AVE
4634409077
47issue1
Sheet1
Cell Formulas
RangeFormula
D2D2=A3
E2E2=A4


when you run this code:
VBA Code:
Sub CleanUpSelect1()
    Dim RowA As Range
    Dim cRng As Range
    Dim iCounter As Long

    Set RowA = Sheet1.Range("A2:A" & Sheets("Sheet1").UsedRange.Rows.Count)
    iCounter = 1
    Do
        Set cRng = RowA(iCounter, 1) 'Loop rows
        If CStr(cRng.Value2) = vbNullString Then
            cRng.EntireRow.Delete
        Else
            If Not KeepRow(cRng.Value2) Then
                cRng.EntireRow.Delete  'Delete row
            Else
                iCounter = iCounter + 1 'Advance
            End If
        End If
    Loop While iCounter <= RowA.Rows.Count 'Stop after loop all rows
End Sub
Private Function KeepRow(RowValue As String) As Boolean
    KeepRow = (RowValue Like "########" Or RowValue Like "issue#" Or RowValue Like "######-###")
End Function

It'll format it to this:

Book1.xlsm
ABCDE
1ACCOUNT NUMBERNAMEADDRESSDEVICE IDPROBLEM
2000003-000JOHN DOE16619 SE 1ST AVE29261052issue2
329261052
4issue2
5001002-000CHATEAU BUSINESS PARK-FIC/ABCD LLC16620 SE 1ST AVE
629261052
7issue2
8001002-000MIKE WINTERS16621 SE 1ST AVE
934713349
10issue1
11000902-000LUCY DOE16633 SE 1ST AVE
1233462540
13issue2
14127555-000STEVE SUMMER16656 SE 1ST AVE
1534409077
16issue1
Sheet1
Cell Formulas
RangeFormula
D2D2=A3
E2E2=A4


After that all you have to do is select the two simple references in D&E and double click them to copy it all the way down:

Book1.xlsm
ABCDE
1ACCOUNT NUMBERNAMEADDRESSDEVICE IDPROBLEM
2000003-000JOHN DOE16619 SE 1ST AVE29261052issue2
329261052issue2001002-000
4issue2001002-00029261052
5001002-000CHATEAU BUSINESS PARK-FIC/ABCD LLC16620 SE 1ST AVE29261052issue2
629261052issue2001002-000
7issue2001002-00034713349
8001002-000MIKE WINTERS16621 SE 1ST AVE34713349issue1
934713349issue1000902-000
10issue1000902-00033462540
11000902-000LUCY DOE16633 SE 1ST AVE33462540issue2
1233462540issue2127555-000
13issue2127555-00034409077
14127555-000STEVE SUMMER16656 SE 1ST AVE34409077issue1
1534409077issue10
16issue100
Sheet1
Cell Formulas
RangeFormula
D2:D16D2=A3
E2:E16E2=A4


Still appears kind of "dirty", but the formulas on the 'final_merge' will work. If you're getting #REF after using it, just take the top row that's still formatted correctly, select it all 'A2:K2' and double click the lower right-hand corner and it'll fix itself. Then just sort column A to hide blanks and you 'should' have a nice list.

Heads up: the sheet1 formula is kind of slow. Maybe someone here can see the code and can speed it up. Formulas I'm alright with, and VBA, still a rookie.
 
Upvote 0
Ok, so I tried to follow your last post suggestion with my real data and I ran into some issues.
BTW, before I start VBA Code is great! Much easier than "Format table as" and unchecking unnecessary info.

I think it has some issues with "/" when it's inside the name and address ie.
Name Address
MIKE SCHIOL DIST / K 81305 SE MALCOM WAY/KG HD

Another issue is that formula looks for if the name matches, some names can be the same just different addresses. Only what is unique with every customer is the account number, which never can be the same. From one system account number comes as 001002-000 and from the other as 1002. Can we somehow instead look up account numbers and format it the same way as 1002 format?

I really like KeepRow = (RowValue Like "########" Or RowValue Like "issue#" Or RowValue Like "######-###") because I have total of 3 issues that have unique names and I can add them to that filter ie. Or RowValue Like "issue3".

For some reason once code runs it leaves two lines one the bottom, one starts with GRAND TOTALS: and other User Nick: if you or someone else could remove based on how each line starts that would be awesome.
Obviously, putting DEVICE ID and PROBLEM on its own columns and deleting the rest below would be the best :)

ACCOUNT NUMBER NAME ADDRESS DEVICE ID PROBLEM
000003-000 JOHN DOE 16619 SE 1ST AVE 29261052 issue2
001002-000 MIKE WINTERS 16621 SE 1ST AVE 34713349 issue1
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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