В настоящее время я пишу макрос для списка элементов, который проверяет, выбран ли элемент, и если он выбран, он передает всю соответствующую информацию об элементе на другой лист.Мой код не производит никаких ошибок, но он также не делает то, что я хочу.Я все еще учусь использовать синтаксис VBA, поэтому я могу упустить что-то очень простое, но вот мой код
Sub ExportCableTray()
Dim UOM As Range
Dim QTY As Range
Dim MTL As Range
Dim DMT As Range
Dim IT As Range
Dim IST As Range
Dim num As Range
Dim des As Range
Dim rng As Range, Cell As Range
Dim i As Integer
Dim Seq As Integer
Seq = 1 'Defines the Seq column in the Export Sheet
i = 8 'counter that goes through the cable tray
j = 12 'counter that decides the row value for the Export Sheet
Set rng = Sheets("Cable Tray").Range("I8:I185")
For Each Cell In rng
If Len(Cell) <> 0 Then
Set UOM = Sheets("Cable Tray").Cells(i, 5)
Set QTY = Sheets("Cable Tray").Cells(i, 15)
Set MTL = Sheets("Cable Tray").Cells(i, 7)
Set DMT = Sheets("Cable Tray").Cells(i, 8)
Set IT = Sheets("Cable Tray").Cells(i, 9)
Set IST = Sheets("Cable Tray").Cells(i, 10)
Set num = Sheets("Cable Tray").Cells(i, 2)
Set des = Sheets("Cable Tray").Cells(i, 3)
UOM.Copy Destination:=Sheets("Export Sheet").Cells(j, 4)
QTY.Copy Destination:=Sheets("Export Sheet").Cells(j, 5)
MTL.Copy Destination:=Sheets("Export Sheet").Cells(j, 6)
DMT.Copy Destination:=Sheets("Export Sheet").Cells(j, 7)
IT.Copy Destination:=Sheets("Export Sheet").Cells(j, 8)
IST.Copy Destination:=Sheets("Export Sheet").Cells(j, 9)
Sheets("Export Sheet").Cells(j, 1).Value = Seq
num.Copy Destination:=Sheets("Export Sheet").Cells(j, 2)
des.Copy Destination:=Sheets("Export Sheet").Cells(j, 3)
i = i + 1
Seq = Seq + 1
j = j + 1
End If
Next Cell
End Sub
Возможно, я слишком усложняю вещи, и любая помощь очень ценится!