I need help.
How to put cell wi.Sheets("Data Operação").Range("Q5") in the cell ThisWorkbook.Sheets.Range("P" & rngRow).
If i add, the result equal "" but expected is 100:
wi.Sheets("Data Operação").Range("Q5").Value = ThisWorkbook.Sheets.Range("P" & rngRow).Value
My code
How to put cell wi.Sheets("Data Operação").Range("Q5") in the cell ThisWorkbook.Sheets.Range("P" & rngRow).
If i add, the result equal "" but expected is 100:
wi.Sheets("Data Operação").Range("Q5").Value = ThisWorkbook.Sheets.Range("P" & rngRow).Value
My code
Sub Reportes_Mesp()Dim rRange As Range, filRange As Range, Rng As Range
Dim oList As ListObject
Dim rngFiltCol As Range
Dim dDate As Date
Dim strDate As String
Dim Path As String
Dim SaldoAnterior As String
Dim LastVisibleRow As Long
Dim OpenFileName As String
Dim wb As Workbook
Dim wi As Workbook
Range("A2").Select
With ActiveSheet.AutoFilter.Range
.AutoFilter Field:=17, Criteria1:="SIM", Operator:=xlAnd
Set rngFiltCol = .Offset(1, 0).Resize(.Rows.Count - 1, 1)
If rngFiltCol.Cells.Count = 1 Then 'Only column headers visible
MsgBox "Nada a Reportar. Verificar mapa!"
'Following line turns off all filters
For Each oList In ActiveSheet.ListObjects
oList.AutoFilter.ShowAllData
Next oList
Exit Sub
'Alternative examples to turn off individual filters
'.AutoFilter Field:=5
'.AutoFilter Field:=14
End If
For Each Rng In rngFiltCol.SpecialCells(12).Rows
OpenFileName = "\\srvmeafserver\DAF\Tesouraria\Tesouraria-Bancos\2. Movim.Banc\01. Diário\01. MEA" & Range("B" & Rng.Row) & "" & Range("B" & Rng.Row) & " - " & Range("D" & Rng.Row) & " - " & Range("C" & Rng.Row) & ".xlsx"
OpenFileNames = "\\srvmeafserver\DAF\Tesouraria\Tesouraria-Bancos\2. Movim.Banc\02. MESP\Template\Template_Extracto_Excel_MESP_010917.xls"
Path = "\\srvmeafserver\DAF\Tesouraria\Tesouraria-Bancos\2. Movim.Banc\02. MESP\2017\01. MEA\10" & Range("B" & Rng.Row) & " - " & Range("D" & Rng.Row) & " - " & Range("C" & Rng.Row) & ".xlsm"
SaldoAnterior = Format(Range("O" & Rng.Row), "##,##0.00")
If OpenFileName = "False" Then Exit Sub
Set wi = Workbooks.Open(OpenFileNames, UpdateLinks:=0)
Set wb = Workbooks.Open(OpenFileName, UpdateLinks:=0)
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
With ActiveSheet.AutoFilter.Range
.AutoFilter Field:=1, Operator:=xlAnd, _
Criteria1:=">" & Application.EoMonth(Now, -2), _
Criteria2:="<=" & Application.EoMonth(Now, -1)
On Error Resume Next
LastVisibleRow = .Cells(2, 3).Resize(LastRow - 1, 1).SpecialCells(xlCellTypeVisible).Count
On Error Resume Next
'Get data EXAMPLE
wi.Sheets("Data Operação").Range("L5") = SaldoAnterior
wi.Sheets("Data Operação").Range("G6:G" & LastVisibleRow).Value = wb.Sheets(1).Range("A10:A" & LastRow).SpecialCells(xlCellTypeVisible).Value
wi.Sheets("Data Operação").Range("H6:H" & LastVisibleRow).Value = wb.Sheets(1).Range("D10:D" & LastRow).SpecialCells(xlCellTypeVisible).Value
wi.Sheets("Data Operação").Range("I6:I" & LastVisibleRow).Value = wb.Sheets(1).Range("E10:E" & LastRow).SpecialCells(xlCellTypeVisible).Value
wi.Sheets("Data Operação").Range("L6:L" & LastVisibleRow).Value = wb.Sheets(1).Range("F10:F" & LastRow).SpecialCells(xlCellTypeVisible).Value
wi.SaveAs Filename:=Path, _
FileFormat:=52, CreateBackup:=False
wb.Close SaveChanges:=False
wi.Close SaveChanges:=False
MsgBox (LastVisibleRow & " Done " & LastRow)
End With
Next Rng
End With
End Sub