-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathData Range Editor.bas
47 lines (29 loc) · 1.06 KB
/
Data Range Editor.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Attribute VB_Name = "Data Range Editor"
Public Sub Main()
' This VBA program copyright Vitek2018
' This program takes a range of cells contained in two columns and checks to see if they are within a predetermined allowable range.
' If the cell value is outside of the allowable range, the appropriate subroutine is called.
Dim CellRange As Range
Worksheets("pHData").Activate
Set CellRange = Range("B23:C2266")
For Each cell In CellRange
If (cell.Value <= 6.66) Then
Call IncreaseCellValue(cell)
ElseIf (cell.Value >= 13.00) Then
Call DecreaseCellValue(cell)
End If
Next cell
MsgBox "Done"
End Sub
Private Sub IncreaseCellValue(cell)
' This subroutine keeps increasing the cell value until it is within allowable range
Do
cell.Value = cell.Value + 1
Loop While cell.Value <= 6.66
End Sub
Private Sub DecreaseCellValue(cell)
' This subroutine keeps decreasing the cell value until it is within allowable range
Do
cell.Value = cell.Value - 1
Loop While cell.Value >= 13.00
End Sub