Dim ExcelApp As Application
Dim FileCosti As Workbook
Dim ShCosti As Worksheet
Dim FileMapping As Workbook
Dim ShMapping1 As Worksheet
Dim ShMapping2 As Worksheet
Dim FileCostiName As String
Dim TOTROW, TOTAQ, TOTCC As Long
Dim R, S As Integer
Dim L1, L2, L3, L4 As String
Dim VDC, NOME As String
Rem INIZIALIZZAZIONE
Rem ================
Set ExcelApp = CreateObject("excel.application")
FileCostiName = "C:\COSTI AMS VITA\AAA.xlsx"
Set FileCosti = ExcelApp.Workbooks.Open(FileCostiName)
ExcelApp.Visible = False
Set ShCosti = FileCosti.Worksheets("Feb19")
Set FileMapping = ExcelApp.Workbooks.Open("C:\COSTI AMS VITA\MappingCosti.xlsx")
Set ShMapping1 = FileMapping.Worksheets("AQSRC003")
Set ShMapping2 = FileMapping.Worksheets("CC Costs")
TOTROW = ShCosti.Cells.SpecialCells(xlCellTypeLastCell).Row
TOTAQ = ShMapping1.Cells.SpecialCells(xlCellTypeLastCell).Row
TOTCC = ShMapping2.Cells.SpecialCells(xlCellTypeLastCell).Row
For R = 2 To TOTROW
VDC = ShCosti.Cells(R, 3).Value
Thanks Paul anyway.
The last statement VDC = ShCosti.Cells(R, 3).Value assigns "Empty" value to VDC variable. I'm sure the cell contains a not empty string.
The strange thing is that with the same code used in another file, it works.
It seems that the cells of the sheet ShCosti are "protected from reading"