2016-09-02 16 views
0

當涉及到代碼時,我是一個總的noob,因此對於您即將看到的內容表示歉意。在使用某些變量的外部工作簿上使用= MAX

我有一份工作簿,其中包含來自供應商的訂單清單及其價值。我正在嘗試創建一個可以執行以下操作的宏,但是我正遇到一堵磚牆。

enter image description here

我所需的宏檢查活動行的小區B,然後訪問他們超鏈接簿並輸出在有源行的單元格的d = MAX值。

Sub Find_PO_Total() 

Range("Supplier" & ActiveCell.Row).Select 

If Range("Supplier" & ActiveCell.Row) = "Supplier1, Supplier2" Then 
Range("Value" & ActiveCell.Row).Max ("_hyperlink_here_!G1:G709") 

ElseIf Range("Supplier" & ActiveCell.Row) = "Supplier3" Then 
    Range("Value" & ActiveCell.Row).Max ("_hyperlink_here_!H1:H709") 

ElseIf Range("Supplier" & ActiveCell.Row) = "Supplier4, Supplier5" Then 
    Range("Value" & ActiveCell.Row).Max ("_hyperlink_here_!I1:I709") 

End If 
End Sub 

回答

0

我已經做了必要的修改代碼

Sub Find_PO_Total() 

If Cells(ActiveCell.Row, 2).Value = "Supplier1" Or Cells(ActiveCell.Row, 2).Value = "Supplier2" Then 
    Cells(ActiveCell.Row, 4).Value = "=MAX(_hyperlink_here_!G1:G709)" 

ElseIf Cells(ActiveCell.Row, 2).Value = "Supplier3" Then 
    Cells(ActiveCell.Row, 4).Value = "=MAX(_hyperlink_here_!H1:H709)" 

ElseIf Cells(ActiveCell.Row, 2).Value = "Supplier4" Or Cells(ActiveCell.Row, 2).Value = "Supplier5" Then 
    Cells(ActiveCell.Row, 4).Value = "=MAX(_hyperlink_here_!I1:I709)" 
End If 

End Sub