0
我有下面的代碼,但當我嘗試運行宏時出現錯誤。
基於我的宏有一個移動列取決於標準。因此我添加了代碼來獲取列號。見ColRef1
。
我遇到的問題是當我試圖將這添加到我的IF和公式。問題在於公式的第一部分,也許我寫錯了。 IF(AND(RC&ColRef1&>0,U2>0)
VBA中頻和公式與參考RC範圍
Sub Test()
Dim GetRow1 As Integer
Dim GetRow2 As Integer
Dim GetRow3 As Integer
Dim GetCol1 As Range
Dim GetCol2 As Range
Dim ColRef1 As Integer
'finds last row on Client Options tab
Sheets("Client Options").Select
GetRow1 = ActiveSheet.Cells(Rows.Count, "G").End(xlUp).Row
'finds last row on Client Response tab
Sheets("Client Response").Select
GetRow2 = ActiveSheet.Cells(Rows.Count, "E").End(xlUp).Row
'finds last row on Recon tab
Sheets("Recon").Select
GetRow3 = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Row
'finds Column that contains Client Options since this is a moving column depending on number of brokers on recon
Sheets("Recon").Select
Set GetCol1 = ActiveSheet.UsedRange.Find("Client Options", , xlValues, xlWhole)
ColRef1 = GetCol1.Column
Sheets("Recon").Select
Range("B2").Value = "=IF(AND(RC&ColRef1&>0,U2>0),""FALSE"",IF(T2>0,(VLOOKUP(A2,'Client Options'!G$2:L$" & GetRow1 & ",6,FALSE)),IF(U2>0,(VLOOKUP(A2,'Client Response'!E$2:G$" & GetRow2 & ",3,FALSE)))))"
End Sub
你做了我的一天。這很有魅力。感謝您的幫助和建議。非常感激!!! – Conor