Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. dim rng as range
  2. with thisworkbook '<~~ possibly set an external workbook
  3. with .worksheets("sheet1")
  4. set rng = .range(cells(2, 1), cells(rows.count, 1).end(xlup))
  5. end with
  6. end with
  7.  
  8. Run-tim error '1004': Application-defined or object-defined error
  9.  
  10. dim rng as range
  11. with thisworkbook '<~~ possibly set an external workbook
  12. with .worksheets("sheet1")
  13. ' define rng as Sheet1!A2 to the last populated cell in Sheet1!A:A
  14. set rng = .range(.cells(2, 1), .cells(rows.count, 1).end(xlup)) '<~~ .range
  15. end with
  16. end with
  17. debug.print rng.address(0, 0, external:=true)
  18.  
  19. dim rng as range
  20. with thisworkbook '<~~ possibly set an external workbook
  21. with .worksheets("sheet1")
  22. ' define rng as Sheet1!A2 to the last populated cell in Sheet1!A:A
  23. set rng = range(.cells(2, 1), .cells(rows.count, 1).end(xlup)) '<~~ range not .range
  24. end with
  25. end with
  26. debug.print rng.address(0, 0, external:=true)
  27.  
  28. '~~> This code fails
  29. set rng = range(.cells(2, 1), .cells(rows.count, 1).end(xlup))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement