VBA Code for Index Match on Customer Data Sheet - Data Enrichment

JTPaint005

New Member
Joined
Mar 15, 2017
Messages
2
Hi All,
First time poster beginner/intermediate vba coder. I've used userforms and input boxes in the past to build financial models but nothing like what I'm trying to do now.

Situation:
I have a large Master Data File ~25mb excel file that uses an AFO to pulls customer information from a SAP BI system.
This information included in columns are:

  • Account # (Unique ID)
  • Account Name
  • Street Address
  • Postal Code
  • State
  • Customer Hierarchy Level (CHL) information
    • 1
    • 2
    • 3
    • 4
    • 5

Then on the right I have manually manipulated cells that depend on other worksheets to get the proper values.

The key columns include:

  • Zone
  • District
  • Group
  • Sub-group
  • Buying Consortium
  • Local/ND
  • Buying Consortium #
  • Buying Consortium GROUP
  • Buying Consortium Sub-GROUP
  • NEW Buying Consortium #
  • Joined Buying Consortium
  • Left Buying Consortium

Now the purpose of this excel sheet is to make quicker changes at the customer level to reflect reporting. I'm desperately looking for concise and quick VBA code that would be able to perform all of the manual manipulations based on an already set criteria.

I'm first starting small and trying to create a VBA script, initiated by buttons in a userform (can think of ui later), that would find the next blank cell in columns [Zone] and [District] using a reference sheet or workbook (whichever would be faster).

The next idea would be the same for the other columns; however, the other columns may need multiple MATCH criteria but lets start with the easy one first. [Zone] and [District]. I have the following syntax from a macro but this would slow down the workbook its huge like 20mb.


Code:
Sub Zone_District()
'
' Zone_District Macro
' Index Match Zone and District Based on Postal Code
'

'
    ActiveCell.FormulaR1C1 = _
        "=IFERROR(INDEX('MD ZIP 2017'!$F:$F,MATCH(Forum!$I2,'MD ZIP 2017'!$C:$C,0)),""Not Assigned"")"
    Range("AD2").Select
    Selection.NumberFormat = "General"
    ActiveCell.FormulaR1C1 = _
        "=IFERROR(INDEX('MD ZIP 2017'!C6,MATCH(Forum!RC9,'MD ZIP 2017'!C3,0)),""Not Assigned"")"
    Range("AD2").Select
    Selection.AutoFill Destination:=Range("AD2:AE2"), Type:=xlFillDefault
    Range("AD2:AE2").Select
    Range("AE2").Select
    ActiveCell.FormulaR1C1 = _
        "=IFERROR(INDEX('MD ZIP 2017'!C7,MATCH(Forum!RC9,'MD ZIP 2017'!C3,0)),""Not Assigned"")"
    Range("AD2:AE2").Select
    Selection.AutoFill Destination:=Range("AD2:AE5"), Type:=xlFillDefault
    Range("AD2:AE5").Select
End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,215,432
Messages
6,124,860
Members
449,194
Latest member
HellScout

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