snasui.com ยินดีต้อนรับ ยินดีต้อนรับสู่กระดานถามตอบ Excel and VBA และอื่น ๆ ที่เป็นมิตรกับทุกท่าน มีไฟล์แนบมหาศาล ช่วยให้ท่านค้นหาและติดตามศึกษาได้โดยง่าย สมาชิกท่านใดที่ยังไม่ได้ระบุ Version ของ Excel ที่ใช้งานจริง สามารถทำตาม Link นี้เพื่อจะได้รับคำตอบที่ตรงกับ Version ของท่านครับ ระบุ Version ของ Excel
สอบถามครับ
ต้องการเพิ่มบรรทัดจากคอลัมน์ที่ระบุค่าไว้ แล้วก๊อปปี้และวางค่าจากบรรทัดด้านบนในบรรทัดที่เพิ่มขึ้น
ตอนนี้ติดปัญหา Code Copy & Paste value แบบ Range ครับ
ขอบคุณครับ
Sub InstRow()
Dim i As Integer, n As Integer, m As Long, currentCell As Range
Set currentCell = ActiveCell
Do While Not IsEmpty(currentCell)
n = currentCell.Value - 1
m = currentCell.Row
If n > 0 Then
Rows(m + 1 & ":" & m + n).Insert
Set currentCell = currentCell.Offset(n + 1, 0)
Else
Set currentCell = currentCell.Offset(1, 0)
End If
Loop
End Sub
สอบถามครับ
ต้องการเพิ่มบรรทัดจากคอลัมน์ที่ระบุค่าไว้ แล้วก๊อปปี้และวางค่าจากบรรทัดด้านบนในบรรทัดที่เพิ่มขึ้น
ตอนนี้ติดปัญหา Code Copy & Paste value แบบ Range ครับ
ขอบคุณครับ
Sub InstRow()
Dim i As Integer, n As Integer, m As Long, currentCell As Range
Set currentCell = ActiveCell
Do While Not IsEmpty(currentCell)
n = currentCell.Value - 1
m = currentCell.Row
If n > 0 Then
Rows(m + 1 & ":" & m + n).Insert
Set currentCell = currentCell.Offset(n + 1, 0)
Else
Set currentCell = currentCell.Offset(1, 0)
End If
Loop
End Sub
Dim i As Integer
Dim n As Integer
With Sheets("Before")
i = .Range("e" & .Rows.Count).End(xlUp).Row
Do While i > 6
n = .Cells(i, "e").Value - 1
If n > 0 Then
.Cells(i, "e").Offset(1, 0).Resize(n).EntireRow.Insert xlDown
.Cells(i, "e").EntireRow.Copy .Cells(i, "e").EntireRow.Resize(n + 1)
.Cells(i, "e").Offset(1, 0).Resize(n).ClearContents
End If
i = i - 1
Loop
End With