Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. Function addSimulation()
  2. ' adds new row of simulation data
  3.  
  4. On Error GoTo ERROR
  5.  
  6. Dim tbl As ListObject
  7. Set tbl = ActiveSheet.ListObjects("TabelleSimulation")
  8.  
  9. Dim newrow As ListRow
  10.  
  11. ' add row on **SECOND** place - only to make sure data validation fields are copied as well
  12. Set newrow = tbl.ListRows.Add(2)
  13. With newrow
  14. .Range(1) = "some data"
  15. .Range(2) = Date
  16. .Range(3) = "more data"
  17. .Range(1).Select ' select a cell, so this row can be moved
  18. End With
  19.  
  20. ' move row one up
  21. Selection.EntireRow.Cut
  22. Selection.Offset(-1, 0).EntireRow.Insert shift:=xlDown
  23. GoTo Ende
  24.  
  25. ERROR:
  26. 'Bei Error:
  27.  
  28. GoTo Ende
  29.  
  30. Ende:
  31. ' ENDE!
  32.  
  33. End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement