Примечание. Я пытаюсь выполнить это на Mac.
У меня есть несколько рабочих книг с информацией о счете-фактуре, изложенной в формате счета-фактуры, и мне нужно извлечь на них различные фрагменты данных и скомпилировать таблицукоторые можно импортировать в другое программное обеспечение.
Вот код, который я написал:
Sub GetFile()
Dim fNameAndPath As Variant
Dim wbdata As Workbook
Dim wbsource As Workbook
Dim ShToCopy As Worksheet
Dim rangedata As Range
'set data workbook
Set wbdata = ThisWorkbook
Set rangedata = ActiveCell
'open other workbook and set as source workbook
fNameAndPath = Application.GetOpenFilename
If fNameAndPath = False Then Exit Sub
Set wbsource = Workbooks.Open(fNameAndPath)
Set ShToCopy = wbsource.Worksheets("PCO #")
Call Extract_Invoice_Data_1(wbdata, wbsource, ShToCopy, rangedata)
Call Extract_Invoice_Data_2(wbdata, wbsource, ShToCopy)
Call Extract_Invoice_Data_3(wbdata, wbsource, ShToCopy)
Call Extract_Invoice_Data_4(wbdata, wbsource, ShToCopy)
Call Extract_Invoice_Data_5(wbdata, wbsource, ShToCopy)
Call Extract_Invoice_Data_6(wbdata, wbsource, ShToCopy)
Call Extract_Invoice_Data_7(wbdata, wbsource, ShToCopy)
Call Extract_Invoice_Data_8(wbdata, wbsource, ShToCopy)
Call Extract_Invoice_Data_9(wbdata, wbsource, ShToCopy)
Call Extract_Invoice_Data_10(wbdata, wbsource, ShToCopy)
Call Extract_Invoice_Data_11(wbdata, wbsource, ShToCopy)
wbsource.Close SaveChanges:=False
Set wbsource = Nothing
End Sub
Sub Extract_Invoice_Data_1(wbdata As Workbook, wbsource As Workbook,
ShToCopy As Worksheet, rangedata As Range)
rangedata.Value = ShToCopy.Range("G5").Value
ActiveCell.Offset(0, 1).Activate
End Sub
Sub Extract_Invoice_Data_2(wbdata As Workbook, wbsource As Workbook,
ShToCopy As Worksheet)
Set rangedata = ActiveCell
rangedata.Value = ShToCopy.Range("G4").Value
ActiveCell.Offset(0, 1).Activate
End Sub
Sub Extract_Invoice_Data_3(wbdata As Workbook, wbsource As Workbook,
ShToCopy As Worksheet)
Set rangedata = ActiveCell
rangedata.Value = ShToCopy.Range("C3").Value
ActiveCell.Offset(0, 1).Activate
End Sub
Sub Extract_Invoice_Data_4(wbdata As Workbook, wbsource As Workbook,
ShToCopy As Worksheet)
Set rangedata = ActiveCell
rangedata.Value = ShToCopy.Range("C4").Value
ActiveCell.Offset(0, 1).Activate
End Sub
Sub Extract_Invoice_Data_5(wbdata As Workbook, wbsource As Workbook,
ShToCopy As Worksheet)
Set rangedata = ActiveCell
rangedata.Value = ShToCopy.Range("C5").Value
ActiveCell.Offset(0, 1).Activate
End Sub
Sub Extract_Invoice_Data_6(wbdata As Workbook, wbsource As Workbook,
ShToCopy As Worksheet)
Set rangedata = ActiveCell
rangedata.Value = ShToCopy.Range("C6").Value
ActiveCell.Offset(0, 1).Activate
End Sub
Sub Extract_Invoice_Data_7(wbdata As Workbook, wbsource As Workbook,
ShToCopy As Worksheet)
Set rangedata = ActiveCell
rangedata.Value = ShToCopy.Range("G32").Value
ActiveCell.Offset(0, 1).Activate
End Sub
Sub Extract_Invoice_Data_8(wbdata As Workbook, wbsource As Workbook,
ShToCopy As Worksheet)
Set rangedata = ActiveCell
rangedata.Value = ShToCopy.Range("G25").Value
ActiveCell.Offset(0, 1).Activate
End Sub
Sub Extract_Invoice_Data_9(wbdata As Workbook, wbsource As Workbook,
ShToCopy As Worksheet)
Set rangedata = ActiveCell
rangedata.Value = ShToCopy.Range("G28").Value
ActiveCell.Offset(0, 1).Activate
ActiveCell = "=RC[-1]*0.15"
ActiveCell.Offset(0, 1).Activate
End Sub
Sub Extract_Invoice_Data_10(wbdata As Workbook, wbsource As Workbook,
ShToCopy As Worksheet)
Set rangedata = ActiveCell
rangedata.Value = ShToCopy.Range("G21").Value
ActiveCell.Offset(0, 1).Activate
End Sub
Sub Extract_Invoice_Data_11(wbdata As Workbook, wbsource As Workbook,
ShToCopy As Worksheet)
Set rangedata = ActiveCell
rangedata.Value = ShToCopy.Range("G22").Value
ActiveCell.Offset(0, 1).Activate
ActiveCell = "=RC[-1]*0.15"
ActiveCell.Offset(0, 1).Activate
ActiveCell = "=SUM(RC[-4]:RC[-1])"
ActiveCell.Offset(0, 1).Activate
End Sub
Проблема в том, что он будет вводить данные только в первую ячейку таблицы данных изатем не извлекать какие-либо другие данные.Пожалуйста, помогите!