The macro stopped working for me, I don't know why, it should copy data from data_wb.Sheets to wbMe. data_wb should run in the shade. There is no error, however, the data is not looking, as if it would not know in which tab. should in "Adekwatnosc" someone knows why? when I go after f8, it jumps straight away "Set loc = .Cells.Find (what: = vDate)
If Not loc Is Nothing Then do to end if "
If Not loc Is Nothing Then do to end if "
VBA Code:
Dim vDate As Date
Dim wbMe As Workbook
Dim ws As Worksheet
Dim inputbx As String
Dim loc As Range, lc As Long
Dim MyFolder As String, ThisMonth As String
Dim MyFile As String
'Zmieniamy nagłówek na short date w pliku z makrem'
Set wbMe = ActiveWorkbook
With wbMe.Sheets("input_forecast").Rows("1:1")
.Copy
.PasteSpecial Paste:=xlPasteValues
.NumberFormat = "YYYY-MM-DD"
End With
'Otwieramy plik automatycznie ze wskazanego folderu'
MyFolder = "C:\Users\V1410190\Documents\FOLDERY ROBOCZE"
MyFile = Dir(MyFolder & "\Kopia PKO BH Plan kroczac1*.xlsm")
If MyFile <> "" Then
Set data_wb = Workbooks.Open(MyFolder & "\" & MyFile, UpdateLinks:=0)
Else
Exit Sub
End If
'Usuwamy alerty o akutliazacji itp'
Application.ThisWorkbook.UpdateLinks = xlUpdateLinksNever '2
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Application.AskToUpdateLinks = False
'Zmieniamy nagłówek na short date w pliku z planem kroczącym'
With data_wb.Sheets("Adekwatnosc").Rows("1:1")
.Value = .Value
.NumberFormat = "YYYY-MM-DD"
End With
'input box - wpisujemy date zgodnie z podanym formatem'
Do
inputbx = InputBox("Enter Date, FORMAT; YYYY-MM-DD", Format(VBA.Now, "YYYY-MM-DD"))
If inputbx = vbNullString Then Exit Sub
On Error Resume Next
vDate = DateValue(inputbx)
On Error GoTo 0
DateIsValid = IsDate(vDate)
If Not DateIsValid Then MsgBox "Please enter a valid date.", vbExclamation
Loop Until DateIsValid
' Wyszukujemy find daty w nagłówku -> kopiujemy -> wklejamy je do pliku z makrem we wskazane w makrze miejscu'
With data_wb.Worksheets("Adekwatnosc")
Set loc = .Cells.Find(what:=vDate)
If Not loc Is Nothing Then
lc = .Cells(loc.Row, Columns.Count).End(xlToLeft).Column
.Range(.Cells(109, loc.Column), .Cells(123, lc)).Copy
Set locPaste = wbMe.Sheets("input_forecast").Cells.Find(what:=vDate)
wbMe.Sheets("input_forecast").Cells(27, locPaste.Column).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
lc1 = .Cells(loc.Row, Columns.Count).End(xlToLeft).Column
.Range(.Cells(138, loc.Column), .Cells(138, lc1)).Copy
Set locPaste = wbMe.Sheets("input_forecast").Cells.Find(what:=vDate)
wbMe.Sheets("input_forecast").Cells(21, locPaste.Column).PasteSpecial Paste:=xlPasteValues
Application.CutCopyMode = False
End If
End With
'Zamykamy plik bez zapisywania'
data_wb.Close SaveChanges:=False