Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub test()
- Dim Arr() As Range
- Arr = Range("A1:A10")
- Dim counter As Integer
- For counter = LBound(Arr) To UBound(Arr)
- Arr.Cells MsgBox(Arr.Cells().Cells(counter, 1).Value)
- 'If Arr(counter) > Arr(counter + 1) Then
- ' MsgBox (counter)
- 'End If
- Next counter
- MsgBox ("Hello, world!")
- End Sub
- Sub Program()
- Dim rangeValues() As Variant
- Dim x As Long
- Dim counter As Integer
- 'Resize Array prior to size of Selected Range
- ReDim rangeValues(Selection.Cells.Count)
- 'Loop through each cell in Selected Range and store value in Array
- For Each cell In Selection
- rangeValues(x) = cell.Value
- x = x + 1
- Next cell
- 'Do work
- counter = 0
- Debug.Print ("Positions of elements matching the required condition")
- For i = LBound(rangeValues) To UBound(rangeValues) - 2
- If rangeValues(i) > rangeValues(i + 1) Then
- Debug.Print (i + 1)
- counter = counter + 1
- End If
- Next i
- Debug.Print ("Amount of the elements " & counter)
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement