2016-03-18 119 views
-1

我一直在試圖製作一個命令按鈕來在Excel中用長公式填充一列。 下面是公式:用長公式填充一列VBA

=CONCATENATE(IFERROR(IF(ISNUMBER(SEARCH('Tagging Inputs'!$C$4,'Template Ideas'!D2))=TRUE,VLOOKUP('Tagging Inputs'!$C$4,'Tagging Inputs'!$B$12:$C$38,2,FALSE),""),""),IF(AND(ISNUMBER(SEARCH('Tagging Inputs'!$C$4,'Template Ideas'!D2)),OR(ISNUMBER(SEARCH('Tagging Inputs'!$C$5,'Template Ideas'!D2)),ISNUMBER(SEARCH('Tagging Inputs'!$C$6,'Template Ideas'!D2)),ISNUMBER(SEARCH('Tagging Inputs'!$C$7,'Template Ideas'!D2)),ISNUMBER(SEARCH('Tagging Inputs'!$C$8,'Template Ideas'!D2))))=TRUE,"; ",""),IFERROR(IF(ISNUMBER(SEARCH('Tagging Inputs'!$C$5,'Template Ideas'!D2))=TRUE,VLOOKUP('Tagging Inputs'!$C$5,'Tagging Inputs'!$B$12:$C$38,2,FALSE),""),""),IF(AND(ISNUMBER(SEARCH('Tagging Inputs'!$C$5,'Template Ideas'!D2)),OR(ISNUMBER(SEARCH('Tagging Inputs'!$C$6,'Template Ideas'!D2)),ISNUMBER(SEARCH('Tagging Inputs'!$C$7,'Template Ideas'!D2)),ISNUMBER(SEARCH('Tagging Inputs'!$C$8,'Template Ideas'!D2))))=TRUE,"; ",""),IFERROR(IF(ISNUMBER(SEARCH('Tagging Inputs'!$C$6,'Template Ideas'!D2))=TRUE,VLOOKUP('Tagging Inputs'!$C$6,'Tagging Inputs'!$B$12:$C$38,2,FALSE),""),""),IF(AND(ISNUMBER(SEARCH('Tagging Inputs'!$C$6,'Template Ideas'!D2)),OR(ISNUMBER(SEARCH('Tagging Inputs'!$C$7,'Template Ideas'!D2)),ISNUMBER(SEARCH('Tagging Inputs'!$C$8,'Template Ideas'!D2))))=TRUE,"; ",""),IFERROR(IF(ISNUMBER(SEARCH('Tagging Inputs'!$C$7,'Template Ideas'!D2))=TRUE,VLOOKUP('Tagging Inputs'!$C$7,'Tagging Inputs'!$B$12:$C$38,2,FALSE),""),""),IF(AND(ISNUMBER(SEARCH('Tagging Inputs'!$C$7,'Template Ideas'!D2)),ISNUMBER(SEARCH('Tagging Inputs'!$C$8,'Template Ideas'!D2)))=TRUE,"; ",""),IFERROR(IF(ISNUMBER(SEARCH('Tagging Inputs'!$C$8,'Template Ideas'!D2))=TRUE,VLOOKUP('Tagging Inputs'!$C$8,'Tagging Inputs'!$B$12:$C$38,2,FALSE),""),"")) 

我一直在使用這種格式的命令按鈕

Private Sub CommandButton2_Click() 
Range("AD2").Formula = "" 
Range("AD2", "AD" & Cells(Rows.Count, 1).End(xlUp).Row).FillDown 
End Sub 
+1

你的問題是什麼? –

+1

有些東西告訴我,如果你顯示了一些數據,並且你試圖用數據來完成,我們可以提出一個更小的公式。 FWIW也不需要所有'= TRUE'。據瞭解,如果它是真的,它是第一次。 –

回答

0

像這樣

lrow = Range("AD2", Range("AD" & Rows.Count).End(xlUp)).SpecialCells(xlCellTypeVisible).Count 
Range("AD2:AD" & lrow).Formula = "=CONCATENATE("......)" 

關注您的qoutes "他們變成雙qoutes。

相關問題