Ludzik1993
New Member
- Joined
- Oct 8, 2018
- Messages
- 2
Hi everyone,
I have a problem with referring to a different workbook and it's specific sheet and range to put it to the formula in a cell. I need to refer to a path and file name by using string (maybe there is different option?) because the file name and it's paths can will change every month.
There is my Code so far:
Hope someone have a solution
Thanks!
I have a problem with referring to a different workbook and it's specific sheet and range to put it to the formula in a cell. I need to refer to a path and file name by using string (maybe there is different option?) because the file name and it's paths can will change every month.
There is my Code so far:
Code:
Sub KopiowanieRaportu()
'GENEROWANIE ŚCIEŻKI AKTYWNEGO PLIKU
Dim MF_Name As String
Dim MF_Path As String
MF_Name = Application.ThisWorkbook.Name
MF_Path = Application.ThisWorkbook.Path
'POBIERANIE NUMERU INDEKSU DLA AKTYWNEGO SKOROSZYTU
Dim MF_SheetName As String
MF_SheetName = ActiveSheet.Name
Dim MF_PathToSheet As String
MF_PathToSheet = MF_Path & "\[" & MF_Name & "]" & MF_SheetName & "'!"
Sheets(PG_NazwaSkoroszytu).Range("M2") = MF_PathToSheet
'PRZYPISYWANIE NAZWY PLIKU MIESIECZNYCH TAPORTOW PER SPÓŁKA DO STAŁEJ
Dim MonthyRaport As Workbook
'OTWIERANIE RAPORTU PER SPÓŁKA
Application.DisplayAlerts = False
Set MonthyRaport = Workbooks.Open(" ")
'KOPIOWANIE MerService
Application.DisplayAlerts = False
Windows("Wykonanie budżetu GRUPA OEX2018").Activate
Sheets("MS_w").Select
Range("K4").Formula = 'HERE I WANT TO REFER TO STRINGS
Hope someone have a solution
Thanks!