Excel VBA - select an .xlsm file from which to copy the values of some cells and paste them into the workbook you are working on

LukyLuca

New Member
Joined
Jun 21, 2022
Messages
4
Office Version
  1. 2016
Platform
  1. Windows
  2. MacOS
I need help from someone more experienced than me!
I'm working on a master worksheet in which I would like to collect data from other worksheet.
I need that when I press the macro button on the master:
1 - Application.GetOpenFilename - a window will open in which I have to select the .xlsm file from which I want to copy the data
2 - Copy from the opened file the value of cells V2:X2 and AC2:AI2
3 - Paste those values on the row of the master table in which are matched the values of column B ("0000") and C ("00") of the table and cell T2 and U2 of the opened file
4 - cells V2:X2 will correspond to cell D:F and cells AC2:AI2 to cell K:P
The attached green sheet is the master worksheet.

I wasn't able to find any other similar question, I will appreciate your help!
Kind regards
Luca
 

Attachments

  • Screen Shot 2022-06-21 at 6.37.09 PM.jpg
    Screen Shot 2022-06-21 at 6.37.09 PM.jpg
    91.9 KB · Views: 13

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I need help from someone more experienced than me!
I'm working on a master worksheet in which I would like to collect data from other worksheet.
I need that when I press the macro button on the master:
1 - Application.GetOpenFilename - a window will open in which I have to select the .xlsm file from which I want to copy the data
2 - Copy from the opened file the value of cells V2:X2 and AC2:AI2
3 - Paste those values on the row of the master table in which are matched the values of column B ("0000") and C ("00") of the table and cell T2 and U2 of the opened file
4 - cells V2:X2 will correspond to cell D:F and cells AC2:AI2 to cell K:P
The attached green sheet is the master worksheet.

I wasn't able to find any other similar question, I will appreciate your help!
Kind regards
Luca
Please, is there anybody who could help me?
 
Upvote 0
So far I have managed to get here!

Below you will find a code to import a range from a selected file to the active workbook. The macro is assigned to a button on the active workbook.

What I miss, and I'm not able to write is that I would like to paste the Range("U2:AH2") on the row of the active worksheet where the value of cell T2 (cell T2 is in the opened file) match a value in column D of the table in the active worksheet.

Sub Import_QTN_Data()

Dim FileToOpen As Variant
Dim OpenBook As Workbook

Application.ScreenUpdating = False

FileToOpen = Application.GetOpenFilename(Title:="Browse for your File & Import Range", FileFilter:="Excel Files (*.xls*),*xls*")
If FileToOpen <> False Then
Set OpenBook = Application.Workbooks.Open(FileToOpen)
OpenBook.Worksheets("QUOTATION").Range("U2:AH2").Copy
ThisWorkbook.Worksheets("QUOTATION").Range("E30").PasteSpecial xlPasteValues, skipblanks:=True

OpenBook.Close False
End If

Application.ScreenUpdating = True

End Sub

Hope that somebody could help me in write this part of the code.
Many thanks in advance

Luca
 
Upvote 0

Forum statistics

Threads
1,223,703
Messages
6,173,941
Members
452,539
Latest member
delvey

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