Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. Sub sel_to_array()
  2.  
  3. Dim arr As Variant
  4. Dim i
  5.  
  6. Sheets("Ps").Activate
  7. Sheets("Ps").Range("C6").Select
  8. Range(Selection, Selection.End(xlDown)).Select
  9.  
  10. 'arr = ActiveCell.CurrentRegion.Value
  11. arr = Selection
  12.  
  13. For Each i In arr
  14. MsgBox i
  15.  
  16. If Round(i, 0) = Round(proj_cbox.Value, 0) Then
  17. GoTo 1:
  18. End If
  19.  
  20. Next i
  21.  
  22. End Sub
  23.  
  24. Sub sel_to_array()
  25.  
  26. Dim arr As Range, rng As Range, cell As Range
  27. Dim lastRow As Long
  28.  
  29. Sheets("Ps").Activate
  30. lastRow = Sheets("Ps").Range("C" & Rows.Count).End(xlUp).Row
  31.  
  32. If lastRow <= 5 Then Exit Sub
  33.  
  34. Set rng = Range("C6:C" & lastRow)
  35.  
  36. For Each cell In rng
  37. If Round(cell.Value, 0) = Round(proj_cbox.Value, 0) Then
  38. MsgBox cell.Address
  39. End If
  40. Next
  41.  
  42. End Sub
  43.  
  44. Sub sel_to_address()
  45. Dim MyRange As Range
  46. For Each MyRange In Range(Sheets("Ps").Range("C6"), Sheets("Ps").Range("C6").End(xlDown))
  47. MsgBox MyRange.Value
  48. If Round(MyRange.Value, 0) = Round(proj_cbox.Value, 0) Then
  49. MsgBox MyRange.Address
  50. End If
  51. Next MyRange
  52. End Sub
  53.  
  54. MsgBox i.Address
  55.  
  56. Set arr = Selection 'set here forces arr to a range object
  57.  
  58. If Round(i, 0) = Round(proj_cbox.Value, 0) Then
  59. With i.Interior
  60. .Pattern = xlSolid
  61. .ColorIndex = 36 'Light Yellow
  62. End With
  63. Else
  64. i.Interior.ColorIndex = xlNone
  65. End If
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement