Bom dia,
Entretanto já consegui construir uma macro, no entanto está a dar-me um erro que não consigo perceber o porquê, assinalei a linha com <--------
Option Explicit
Sub Teste()
Dim Wsht As Worksheet, WbkCF As Workbook, WbkPF As Workbook, Path As String, WshtTA As Worksheet, WshtFR As Worksheet
Dim cell As Range, WshtCR As Worksheet, Rng As Range
Set WbkPF = Workbooks("Pag_Fornecedores_2015 - Template.xlsb")
With WbkPF
Set WshtFR = .Worksheets("Facturas-Requisições")
Set WshtTA = .Worksheets("Tabelas Auxiliares")
End With
With WshtTA
Path = .Range("G14")
If Right(Path, 1) <> "\" Then
Path = Path & "\"
Else
Path = Path
End If
End With
Set WbkCF = Workbooks.Open(Path & "Conferência de facturas - Template.xlsb", UpdateLinks:=True, ReadOnly:=True)
Debug.Print WbkCF.Name
' Desbloquear todas as worksheets
For Each Wsht In WbkPF.Worksheets
With Wsht
If .ProtectContents Then
.Unprotect Password:="--------" '<----------COLOCAR PASSWORD
End If
End With
Next Wsht
' copiar informação da worksheet "Conferências Req." do workbook "Conferência Facturas" para a worksheet "Facturas-Requisições" do workbook "Pag_Fornecedores_2015 - Template"
' sempre que esteja registado "OK" na coluna R da worksheet "Conferências Req." do workbook "Conferência Facturas"
Set WshtCR = WbkCF.Worksheets("Conferências Req.")
With WshtCR
For Each cell In .Range("s8:s" & .Range("s1048576").End(xlUp).Row)
If cell.Value = "OK" Then
With WshtFR
Set Rng = .Range("H:H").Find(what:=cell.Offset(0, -7), LookIn:=xlValues, lookat:=xlWhole)
If Rng Is Nothing Then
' adicionar prazo pagamento
' código abaixo copia a data da factura worksheet "Conferências Req." do workbook "Conferência Facturas" para a worksheet "Facturas-Requisições" do workbook "Pag_Fornecedores_2015 - Template"
cell.Offset(0, -7).Copy
.Cells(.Range("1048576").End(xlUp).Row + 1,
.PasteSpecial xlPasteValues <-----------
' adicionar restante código para copiar restante informação de interesse
End If
End With
End If
Next cell
End With
End Sub
Obrigado
CJCM