แทรกแถวไม่ได้
Posted: Sun Jun 22, 2014 9:48 pm
เรียน คนควน
รบกวนแก้ไข vba ให้สมบูรณ์หน่อยครับ ผมใช้มันแล้วไม่สามารถแทกรแถวได้ครับ ฟ้อง error ตลอด
error ที่ฟ้องคือ To prevent possible loss of data, Excel cannot shift nonblank cell off of the worksheet. Select another location in which to insert new cells, or deletedate. If you do not have data in cell that can be shifted off of the worksheet, you can reset which cell Excel considers nonblank, T^o do this, press CTRT + End to locate the last nonblank cell on the worksheet delete this cell and all cells between it and the last row and column of your data the save.
ส่วน vba ของผมคือ อันนี้ครับ
Sub price()
Worksheets("PRICE ").Select
Range("B4").Select
ActiveCell.FormulaR1C1 = _
"=IF(R2C-1='RATE '!R1C1,VLOOKUP(RC1,'RATE '!R4C1:R4000C6,6,0))"
Selection.AutoFill Destination:=Range("B4:B700")
Range("B4:B700").Select
Columns("B:B").Select
Selection.Copy
Selection.Insert Shift:=xlToRight
Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=RC[1]+1"
Range("B3").Select
End Sub
รบกวนแก้ไข vba ให้สมบูรณ์หน่อยครับ ผมใช้มันแล้วไม่สามารถแทกรแถวได้ครับ ฟ้อง error ตลอด
error ที่ฟ้องคือ To prevent possible loss of data, Excel cannot shift nonblank cell off of the worksheet. Select another location in which to insert new cells, or deletedate. If you do not have data in cell that can be shifted off of the worksheet, you can reset which cell Excel considers nonblank, T^o do this, press CTRT + End to locate the last nonblank cell on the worksheet delete this cell and all cells between it and the last row and column of your data the save.
ส่วน vba ของผมคือ อันนี้ครับ
Sub price()
Worksheets("PRICE ").Select
Range("B4").Select
ActiveCell.FormulaR1C1 = _
"=IF(R2C-1='RATE '!R1C1,VLOOKUP(RC1,'RATE '!R4C1:R4000C6,6,0))"
Selection.AutoFill Destination:=Range("B4:B700")
Range("B4:B700").Select
Columns("B:B").Select
Selection.Copy
Selection.Insert Shift:=xlToRight
Columns("C:C").Select
Application.CutCopyMode = False
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Range("B2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=RC[1]+1"
Range("B3").Select
End Sub