ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

excel ¥¨¶° ³o¬O¨º¿ù¤F¡H¥X²{°õ¦æ¶¥¬q¿ù»~1004À³¥Îµ{¦¡©Îª«¥ó©w¸q¤W¿ù»~

excel ¥¨¶° ³o¬O¨º¿ù¤F¡H¥X²{°õ¦æ¶¥¬q¿ù»~1004À³¥Îµ{¦¡©Îª«¥ó©w¸q¤W¿ù»~

excel ¥¨¶° ³o¬O¨º¿ù¤F¡H¥X²{°õ¦æ¶¥¬q¿ù»~1004À³¥Îµ{¦¡©Îª«¥ó©w¸q¤W¿ù»~

³o¬O¤@­Ó²³æªº excel

§Ú­n¦b H18~H268  ¶ñº¡¤½¦¡¡G
'=IF(COUNTIF($B$18:$B18,$B18)=1,SUMIF($B$18:$B$267,B18,$G$18:$G$267),"")
'=IF(COUNTIF($B$18:$B19,$B19)=1,SUMIF($B$18:$B$267,B19,$G$18:$G$267),"")
'=IF(COUNTIF($B$18:$B20,$B20)=1,SUMIF($B$18:$B$267,B20,$G$18:$G$267),"")

§Ú¥Î¥¨¶°¨Ó¨ó§U

Sub Macro1()
'
' Macro1 Macro
' AMD945 ¦b 2017/6/5 ¿ý»sªº¥¨¶°
'
' §Ö³tÁä: Ctrl+u
'
        Dim row_i As Long
                                For row_i = 18 To 258
'=IF(COUNTIF($B$18:$B18,$B18)=1,SUMIF($B$18:$B$267,B18,$G$18:$G$267),"")
'=IF(COUNTIF($B$18:$B19,$B19)=1,SUMIF($B$18:$B$267,B19,$G$18:$G$267),"")
'=IF(COUNTIF($B$18:$B20,$B20)=1,SUMIF($B$18:$B$267,B20,$G$18:$G$267),"")

'Sheets("Sheet1").Cells(row_i, 8) = "=IF(COUNTIF($B$18:$B"&row_i&",$B"&row_i&")=1,SUMIF($B$18:$B$267,B"&row_i&",$G$18:$G$267),"""")"

Sheets("Sheet1").Cells(row_i, 8) = "=IF(COUNTIF($B$18:$B"

                                Next row_i
End Sub

§Ú±N¤½¦¡Âন ¦r¦ê¡A¨Ó¶ñ¤J cell

Sheets("Sheet1").Cells(row_i, 8) = "=IF(COUNTIF($B$18:$B"&row_i&",$B"&row_i&")=1,SUMIF($B$18:$B$267,B"&row_i&",$G$18:$G$267),"""")"
¦ý¬Oµ{¦¡¤@ª½¥X²{  °õ¦æ¶¥¬q¿ù»~1004À³¥Îµ{¦¡©Îª«¥ó©w¸q¤W¿ù»~

§Ú±N¦r¦ê¤@ª½§R¡A§R¨ì

Sheets("Sheet1").Cells(row_i, 8) = "=IF(COUNTIF($B$18:$B"

ÁÙ¬O¦³°ÝÃD¡A§Ú¯uªºµL¯à¬°¤O¤F¡A¬°¤°»ò³o»ò²³æªº¦r¦êÁÙ¯à¿ù¡H

¡°excel 2003 test1.zip (9.9 KB)
¤½¶}¸gÅç¡A³Ð³y´¼¼z¡]§Ú¤S¤£¾a³o¹L¬¡¡^

°Ñ¦Ò¡G https://stackoverflow.com/questions/18574413/weird-run-time-1004-error-with-strings-in-excel-vba

ªþµù¡G string ¦pªG¤£§¹¾ã¡A¥N¤J¤½¦¡´N·|¤@ª½¥X²{ error ¡A¦Ó¥B«ÜÃø§ä

¥i¥H³o¼Ë ¥[¤J ¡y'¡z¸¹
row_str="=IF(COUNTIF($B$18:$B" &row_i& ",$B&18)=1,SUMIF($B$18:$B$267,B"&row_i&",$G$18:$G$267),"")"
row_str="'=IF(COUNTIF($B$18:$B" &row_i& ",$B&18)=1,SUMIF($B$18:$B$267,B"&row_i&",$G$18:$G$267),"")"
Åܦ¨¼g¤J¦r¦ê¡A¦Ó¤£¬O¤½¦¡¡A³o¼Ë¤~¯à§Ö³t°£¿ù
¤½¶}¸gÅç¡A³Ð³y´¼¼z¡]§Ú¤S¤£¾a³o¹L¬¡¡^

TOP

¦Û¤v¸Ñ¡G

'Sheets("Sheet1").Cells(row_i, 8) = "=IF(COUNTIF($B$18B"&row_i&",$B"&row_i&")=1,SUMIF($B$18B$267,B"&row_i&",$G$18G$267),"""")"

dim row_str as string


row_str="=IF(COUNTIF($B$18B"&row_i&",$B"&row_i&")=1,SUMIF($B$18B$267,B"&row_i&",$G$18G$267),"""")"

Sheets("Sheet1").Cells(row_i, 8) = row_str

¶ñ¤J§¹¾ãªº¦r¦ê´N¤£·|¦³error

¦n©_©Ç§r~~~~
¤½¶}¸gÅç¡A³Ð³y´¼¼z¡]§Ú¤S¤£¾a³o¹L¬¡¡^

TOP

        ÀR«ä¦Û¦b : ½_ÁJµ²±o¶V¹¡º¡¡A¶V·|©¹¤U««¡A¤@­Ó¤H¶V¦³¦¨´N¡A´N­n¶V¦³Á¾¨Rªº¯ÝÃÌ¡C
ªð¦^¦Cªí ¤W¤@¥DÃD