Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. Sub Submit1()
  2. Range("A2:C2").Select #in Sheet1
  3. Selection.Copy
  4. Sheets("Sheet2").Select
  5. Worksheets("Sheet2").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0).PasteSpecial
  6. End Submit1
  7.  
  8. Sub Submit1()
  9. Dim nextRow As Long
  10. With Worksheets("Sheet2")
  11. 'Find the last non-empty cell in the worksheet, and determine its row
  12. 'Then add 1 to that, so we are pointing at the next row
  13. nextRow = .Cells.Find(What:="*", _
  14. After:=.Range("A1"), _
  15. Lookat:=xlPart, _
  16. LookIn:=xlFormulas, _
  17. SearchOrder:=xlByRows, _
  18. SearchDirection:=xlPrevious, _
  19. MatchCase:=False).Row + 1
  20. 'Copy values to "nextRow"
  21. Worksheets("Sheet1").Range("A2:C2").Copy .Cells(nextRow, "A")
  22. 'Perform other copies as necessary, e.g.
  23. Worksheets("Sheet1").Range("A5:D5").Copy .Cells(nextRow, "D")
  24. Worksheets("Sheet1").Range("X4:Z4").Copy .Cells(nextRow, "H")
  25. End With
  26. End Sub
  27.  
  28. Sub test()
  29.  
  30. Dim LastRow As Long Dim arCopy() As Variant
  31. Dim rDest As Range
  32.  
  33. With Sheet2 ' --> Qualify the ranges
  34. LastRow = .Cells(.Rows.Count, "A").End(xlUp).Row + 1 End With
  35.  
  36. arCopy = Sheet1.Range("A2:K2").Value
  37.  
  38. Set rDest = Sheet2.Cells(LastRow, "A")
  39.  
  40. Set rDest = rDest.Resize(1, UBound(arCopy, 2))
  41.  
  42. rDest.Value = arCopy
  43.  
  44. End Sub
  45.  
  46. Sheet1.Range("A1")="Rob"
  47. Sheet1.Copy("A2")
  48. Sheet1.Rows.Count
  49.  
  50. With Sheet1
  51. .Range("A1") = "Rob"
  52. .Copy("A2")
  53. .Rows.Count
  54. End With
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement