Guest User

Untitled

a guest
Apr 21st, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. Sub select2()
  2. a1 = Selection.row
  3. ii = 0
  4. '---
  5. For i = 0 To a1 - 2
  6. If Cells(a1 - i, 1) <> "" And Cells(a1 - i, 1) <> "jump" Then
  7. r_up = a1 - i + 1
  8. Exit For
  9. Else
  10. If ii >= 5 Then
  11. r_up = a1 - i + ii
  12. Exit For
  13. Else
  14. If Application.CountA(Rows(a1 - i)) = 0 Then
  15. ii = ii + 1
  16. Else
  17. ii = 0
  18. End If
  19. End If
  20. End If
  21. Next
  22. ii = 0
  23. For i = 1 To 10000
  24. If Cells(i + a1, 1) <> "" And Cells(a1 + i, 1) <> "jump" Then
  25. r_dn = a1 + i - 1
  26. Exit For
  27. Else
  28. If ii >= 5 Then
  29. r_dn = a1 + i - ii - 1
  30. Exit For
  31. Else
  32. If Application.CountA(Rows(a1 + i)) = 0 Then
  33. ii = ii + 1
  34. Else
  35. ii = 0
  36. End If
  37. End If
  38. End If
  39. Next
  40. '---
  41. Range("b" & r_up & ":z" & r_dn).Select
  42. End Sub
Add Comment
Please, Sign In to add comment