Copy my data to my workbook from another and add the name of the intern on the first column

Jeffreyxx01

Board Regular
Joined
Oct 23, 2017
Messages
156
Hi guys,

I need some help on updating my macro,

When I will click on the macro using this one below, I will want to pull the name of the intern and copy automatically in the column A for the number of rows that the intern created on his/her spreadsheet,
I have a lookup table of the name of the intern which can be used to just click on the name to be filled.

the name of the other tab is: Lookups and the name range is A2:A25

Thanks for your help,

Code:
Sub OpenFiles()

   Dim InitPth As String
   Dim Wbk As Workbook
   Dim Cnt As Long
   Dim Sht As Worksheet
   Dim Usdrws As Long
   
   InitPth = "C:\Users\Hosue\Desktop\PE\Master List\Inputs"
   
   With Application.FileDialog(3)
      .Title = "Select the files"
      .AllowMultiSelect = True
      .InitialFileName = InitPth
      If .Show <> -1 Then Exit Sub
   
      For Cnt = 1 To .SelectedItems.Count


    Set Wbk = Workbooks.Open(.SelectedItems(Cnt))
    Set Sht = ThisWorkbook.Sheets("DataBase")
        With Wbk.Sheets("CallSheet")
            LastRow = .Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
            .Range("A2:L" & LastRow).Copy Sht.Range("A" & Rows.Count).End(xlUp).Offset(1)
        End With
            Application.DisplayAlerts = False
            Wbk.Close , False
            Application.DisplayAlerts = True
      Next Cnt
   End With




End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Could this code help building my macro?

Code:
Sub Data_Validation()

Dim Sht As Worksheet


With Sht("Lookups").Range("A2:A25").Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, _
Operator:=xlBetween, Formula1:="=Sheet1!A1:A6"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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