返回列表 上一主題 發帖

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

回復 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

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


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

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

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

回復 13# kimbal

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

TOP

回復 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

        靜思自在 : 多做多得。少做多失。
返回列表 上一主題