Там не просто поменять надо... Вот так работать будет:[vba]
Код
Sub mangasarovdr() Dim WB$, rR WB = ActiveWorkbook.Name Workbooks.Open FileName:="C:\PartsPrice\PartsPrice.xlsx", UpdateLinks:=0 Windows(WB).Activate On Error Resume Next For Each rR In Selection rR.Offset(0, 2) = Application.WorksheetFunction.VLookup(rR, Workbooks("PartsPrice.xlsx").Sheets(1).Range("a1:b10000"), 2, 0) Next rR End Sub
Там не просто поменять надо... Вот так работать будет:[vba]
Код
Sub mangasarovdr() Dim WB$, rR WB = ActiveWorkbook.Name Workbooks.Open FileName:="C:\PartsPrice\PartsPrice.xlsx", UpdateLinks:=0 Windows(WB).Activate On Error Resume Next For Each rR In Selection rR.Offset(0, 2) = Application.WorksheetFunction.VLookup(rR, Workbooks("PartsPrice.xlsx").Sheets(1).Range("a1:b10000"), 2, 0) Next rR End Sub
Я про столбец E "Цена" файла из поста #1 Такой вариант еще получился [vba]
Код
Sub tt() Dim wb0_ As Workbook, wb1_ As Workbook Set wb0_ = ActiveWorkbook Application.ScreenUpdating = 0 Set wb1_ = Workbooks.Open("C:\PartsPrice\PartsPrice.xlsx") With wb1_ With .Worksheets(1) nr1_ = .Cells(.Rows.Count, 1).End(3).Row - 1 ar1_ = .Cells(2, 1).Resize(nr1_, 2).Value End With .Close End With Set slov = CreateObject("Scripting.Dictionary") With slov For i = 1 To nr1_ .Item(ar1_(i, 1)) = ar1_(i, 2) Next i ar0_ = Selection.Resize(, 3).Value For i = 1 To UBound(ar0_) If .exists(ar0_(i, 1)) Then ar0_(i, 3) = .Item(ar0_(i, 1)) Else ar0_(i, 3) = "=RC[3]*1.45" 'ar0_(i, 3) = 0 ' Или так End If Next i End With Selection.Resize(, 3).Value = ar0_ Application.ScreenUpdating = 1 End Sub
Я про столбец E "Цена" файла из поста #1 Такой вариант еще получился [vba]
Код
Sub tt() Dim wb0_ As Workbook, wb1_ As Workbook Set wb0_ = ActiveWorkbook Application.ScreenUpdating = 0 Set wb1_ = Workbooks.Open("C:\PartsPrice\PartsPrice.xlsx") With wb1_ With .Worksheets(1) nr1_ = .Cells(.Rows.Count, 1).End(3).Row - 1 ar1_ = .Cells(2, 1).Resize(nr1_, 2).Value End With .Close End With Set slov = CreateObject("Scripting.Dictionary") With slov For i = 1 To nr1_ .Item(ar1_(i, 1)) = ar1_(i, 2) Next i ar0_ = Selection.Resize(, 3).Value For i = 1 To UBound(ar0_) If .exists(ar0_(i, 1)) Then ar0_(i, 3) = .Item(ar0_(i, 1)) Else ar0_(i, 3) = "=RC[3]*1.45" 'ar0_(i, 3) = 0 ' Или так End If Next i End With Selection.Resize(, 3).Value = ar0_ Application.ScreenUpdating = 1 End Sub