返回列表 上一主題 發帖

[發問] 如何在A欄 自動填上編號

[發問] 如何在A欄 自動填上編號

如何在A欄 自動填上編號,請各位高手指敎這程式碼如何寫? 謝謝!!
A欄          B欄
               1234
               23
               123

               234
               567
               
               123
               678
               4567
               185

完成後
A欄          B欄
1             1234
1             23
1             123

2             234
2             567
               
3             123
3             678
3             4567
3             185

回復 14# john2006168

  1. For Each c In Range([A10], [A65536].End(xlUp)).Offset(0, 5)
  2. c.Value = c.Offset(0, -5).Value & c.Offset(0, -1).Value
  3. Next
複製代碼
換成
  1. i=0
  2. For Each c In Range([A10], [A65536].End(xlUp)).Offset(0, 5)
  3. i=i+1
  4. worksheets("sheet2").range("e1").offset(i) = c.Offset(0, -5).Value & c.Offset(0, -1).Value
  5. Next
複製代碼
懂得發問,答案就會在其中

今日の一秒は  明日にない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

[版主管理留言]
  • Hsieh(2010-7-29 21:23): 自己都不思考,只撿現成,永遠都是發問者

回復 13# kimbal

thanks ,如果我想在sheet2 show 出來應該怎麼寫

TOP

本帖最後由 kimbal 於 2010-7-29 13:28 編輯

加在f欄
  1. Sub nn()
  2. Dim Rng As Range
  3. [A10].Insert xlToRight
  4. [A10] = "plt no"
  5. Set Rng = Range([A11], [A65536].End(xlUp)).SpecialCells(xlCellTypeConstants)
  6. For i = 1 To Rng.Areas.Count
  7.    mystr = Rng.Areas(i).Address
  8.    Rng.Areas(i).Insert xlToRight
  9.    Range(mystr).Value =format( i,"'00")
  10. Next
  11. Range([A11], [A65536].End(xlUp)).SpecialCells(xlCellTypeBlanks).EntireRow.Delete

  12. For Each c In Range([A10], [A65536].End(xlUp)).Offset(0, 5)
  13. c.Value = c.Offset(0, -5).Value & c.Offset(0, -1).Value
  14. Next
  15. End Sub
複製代碼
懂得發問,答案就會在其中

今日の一秒は  明日にない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

Book3.zip (4.62 KB) 回復 11# Hsieh


    多謝老師,另外我想將plt no 加上ref no好像sheet02,請再三幫忙

TOP

回復 10# john2006168
  1. Sub nn()
  2. Dim Rng As Range
  3. [A10].Insert xlToRight
  4. [A10] = "plt no"
  5. Set Rng = Range([A11], [A65536].End(xlUp)).SpecialCells(xlCellTypeConstants)
  6. For i = 1 To Rng.Areas.Count
  7. mystr = Rng.Areas(i).Address
  8.    Rng.Areas(i).Insert xlToRight
  9.    Range(mystr).Value =format( i,"'00")
  10. Next
  11. Range([A11], [A65536].End(xlUp)).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
  12. End Sub
複製代碼
學海無涯_不恥下問

TOP

回復 9# Hsieh


    老師如果plt no用01 ,02,03表示,應該怎麼改

TOP

回復 8# john2006168
  1. Sub nn()
  2. Dim Rng As Range
  3. [A10].Insert xlToRight
  4. [A10] = "plt no"
  5. Set Rng = Range([A11], [A65536].End(xlUp)).SpecialCells(xlCellTypeConstants)
  6. For i = 1 To Rng.Areas.Count
  7. mystr = Rng.Areas(i).Address
  8.    Rng.Areas(i).Insert xlToRight
  9.    Range(mystr).Value = i
  10. Next
  11. Range([A11], [A65536].End(xlUp)).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
  12. End Sub
複製代碼
學海無涯_不恥下問

TOP

本帖最後由 john2006168 於 2010-7-29 00:50 編輯
回復  aoss98
Hsieh 發表於 2010-7-27 22:22


tesst2010.zip (8.4 KB)
    老師,我有類似的問題相同的問題,請問用VBA怎麼寫

tesst2010.zip (8.4 KB)

TOP

謝謝各位指教!!!

TOP

        靜思自在 : 對父母要知恩,感恩、報恩。
返回列表 上一主題