Totally new to VBA, some python experience. All sheets are in the same workbook. I'm trying to search through a column in Sheet1 and if a condition is true, get the value from another column on the same row. I then want to check for duplicates. If duplicates send message error. If no duplicates, sort (data is integers) ascending and write the values to consecutive cells in Sheet2. Also, it'd be nice if the upper limit of the range was variable (i.e. I don't know how long the table in Sheet1 will be and I don't know how many unique values will be returned).
Pseudocode something like this (with example data below):
Sub doSomething()
In Sheet1:
for i in Range(A1:A7)
array() = []
if i = 1
get value from column B
array.append(value from column B)
If duplicates in array()
msgBox("Duplicates exist")
Exit Sub
else:
sort array elements ascending
In Sheet2:
write elements from array() consecutively into cells L5:R5
End Sub
Sheet1
<tbody>
</tbody>
Sheet2
<tbody>
</tbody>
Pseudocode something like this (with example data below):
Sub doSomething()
In Sheet1:
for i in Range(A1:A7)
array() = []
if i = 1
get value from column B
array.append(value from column B)
If duplicates in array()
msgBox("Duplicates exist")
Exit Sub
else:
sort array elements ascending
In Sheet2:
write elements from array() consecutively into cells L5:R5
End Sub
Sheet1
A | B |
1 | 6 |
1 | 5 |
0 | 10 |
0 | 15 |
1 | 3 |
0 | 2 |
<tbody>
</tbody>
Sheet2
L | M | N | O | P | Q | R |
3 | 5 | 6 |
<tbody>
</tbody>