返回列表 上一主題 發帖

儲存格程式該如何陣列循環

回復 1# yueh0720
  1. k1 = ActiveSheet.Range("A1").CurrentRegion.Rows.Count


  2. 簡易的解法..
  3. 另附上 若P有數值,則C-N 以淡藍色顯示


  4. For ap = 1 To k1
  5.     If Cells(ap, "p") <> "" Then
  6.         For ap1 = 3 To 14
  7.         Cells(ap, ap1) = Cells(ap, ap1 + 13)
  8.         
  9.             Cells(ap, ap1).Select
  10.             With Selection.Interior
  11.                 .Pattern = xlSolid
  12.                 .PatternColorIndex = xlAutomatic
  13.                 .ThemeColor = xlThemeColorAccent5
  14.                 .TintAndShade = 0.599993896298105
  15.                 .PatternTintAndShade = 0
  16.             End With

  17.         Next
  18.     End If

  19. Next
複製代碼

  多做多想多學習,少看少錯少迷途

  多做=多多練習,多多編寫。
  多想=想想為什麼人家程式要那樣寫,如果換成自己,又會怎寫。
  多學習=學習人家的發問並解答,學習人家的寫法

  少看=只看不做也枉然

TOP

回復  mark15jill


儲存格C3會出現" ActiveSheet.Paste"
顏色部分會出現錯誤,將此3項忽略則OK
.Th ...
yueh0720 發表於 2013-3-11 11:46




以下這段可選擇要不要+...
                Cells(ap, ap1).Select

            With Selection.Interior

                .Pattern = xlSolid

                .PatternColorIndex = xlAutomatic

                .ThemeColor = xlThemeColorAccent5

                .TintAndShade = 0.599993896298105

                .PatternTintAndShade = 0

            End With



        Next

    End If

  多做多想多學習,少看少錯少迷途

  多做=多多練習,多多編寫。
  多想=想想為什麼人家程式要那樣寫,如果換成自己,又會怎寫。
  多學習=學習人家的發問並解答,學習人家的寫法

  少看=只看不做也枉然

TOP

        靜思自在 : 一句溫暖的話,就像往別人身上灑香水,自己會沾到兩三滴。
返回列表 上一主題