Advertisement
Guest User

Untitled

a guest
May 14th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub ForEachLeft()
  2.  Dim Threshold As Double
  3.  Threshold = 1.15
  4.  
  5.  
  6.  Dim RowIdx As Long
  7.  Dim StartCol As String
  8.  Dim EndCol As String
  9.  'Specify range here:
  10. StartCol = "Z"
  11.  EndCol = "T"
  12.  RowIdx = 7
  13.  
  14.  Dim StartColIdx As Long
  15.  Dim EndColIdx As Long
  16.  StartColIdx = Range(StartCol & 1).Column
  17.  EndColIdx = Range(EndCol & 1).Column
  18.  
  19.  Dim i As Long
  20.  Dim currVal As Double
  21.  For i = StartColIdx To EndColIdx Step -1
  22.   'MsgBox "[" & RowIdx & "," & i & "] Val=" & Cells(RowIdx, i).Value()
  23.  currVal = Cells(RowIdx, i).Value()
  24.   If currVal <= Threshold Then
  25.     MsgBox currVal & "is less or equal to threshold -> subtracting in increments"
  26.   Else
  27.     MsgBox currVal & "is greater than threshold -> skip this cell"
  28.   End If
  29.  Next i
  30. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement