Updating a list based on a different list

Excelquestion35

Board Regular
Joined
Nov 29, 2021
Messages
53
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

Looking for some advice on how to approach the following problem. I have situation where I have to keep track of a masterfile which contains the list of first line managers (FLM) per customer. This list is updated by a macro when people come and go. Thus the pool of FLMs is changing over time.

Next to this, I have a request file in which temp employees will be requested. In this form they have to state who will be there FLM. (dropdown list) This should be an actual list of FLMs and should thus be taken from the master file.

Therefore, I am thinking about creating a macro that updates the FLMs based on the masterfile. I think a for loop is required here, but I am wondering how I can let this loop know:

  • Who belongs to the what operation?
  • The length (amount of rows) that belong to a certain operation?
  • Another question but not belonging to the loop; the name of each operation is not completely identical to that in the master file inside the request file. How can I deal with this? Normally you would have the "contains" Text filter inside filtering.
I think it is best to first delete all FLMs in the request file and then look for the list of FLMs in the masterfile.

Below two pictures to give you an impression of how things look like currently:

Request file
Request file.PNG

Master file
Masterfile.PNG

I am completely aware the code is a bit messy, but I started from scratch and then got stuck:
VBA Code:
Sub UpdatenFLM()
'
' UpdatenFLM Macro
'

'
    Windows("Copy of Site overview (003) - 2.xlsm").Activate
    inarr = ActiveSheet.Range("$B$1:$GZ:50")
    Operation = Sheets("Supervisor (leidinggevende)").Range("B1") 'Every first cell in a column is the operation, use the first as a variable
    


For i = 1 To 207
    Columns(i).Select
    ActiveCell.Offset(0, 0).Range("A1").Select
    Selection.Copy 'Copy the first operation name


    ActiveSheet.Unprotect 'deleting the current list of FLMs
    ActiveCell.Offset(1, 0).Range("A1").Select
    Range(Selection, Selection.End(xlDown)).Select
    Application.CutCopyMode = False
    Selection.ClearContents
    
    Windows("Copy of Site overview (003) - 2.xlsm").Activate 'Look for the new list of FLMs in other sheet
    ActiveSheet.Range("$A$3:$AS$62").AutoFilter Field:=2, Criteria1:="=*Ricoh*" _
        , Operator:=xlAnd 'instead of looking for something that includes Ricoh, how can I change this to the variable without having it to be the exact match?
    
    Range("C52").Select 'First FLM found on this row
    Range(Selection, Selection.End(xlDown)).Select 'Get the whole list of FLMs belonging to this operation
    Application.CutCopyMode = False
    Selection.Copy
    
    Windows( _
        "Kronos Centraal Formulier v3.2 - Template (zonder check) - RPA versie.xlsm"). _
        Activate 'Return to original sheet and then paste the updated list of FLMs below the name of the operation
    Range("B2").Select 'How can I make this dynamic based on the operation?
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    
    
Next i

End Sub
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,224,844
Messages
6,181,291
Members
453,030
Latest member
PG626

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