Menu

Completed Project

I recently started out learning VBA for automating stuff at job. I always feared programming but learning from past 2 months i got some basics and it was fun. I tried to solve the project with the knowledge i got from past 2 months. I am learning new ways people are solving this project. Cheers to all.

 

This are the two subroutines i used for adding and clearing the list:

Sub moving_numbers()

Dim r As Range
Dim cell As Range
Dim targetrow As Long
Dim ws As Worksheet
Dim countmoved As Long

Set ws = ThisWorkbook.Worksheets("Sheet1")

Set r = ws.Range("Number_list")

targetrow = ws.Cells(Rows.Count, "I").End(xlUp).Row + 1

countmoved = 0
For Each cell In r
    If cell.Value < 10 Then
        Cells(targetrow, "I").Value = cell.Value
        
        targetrow = targetrow + 1
        
        countmoved = countmoved + 1
    End If
Next cell
    
MsgBox "Number sorting complete"
End Sub

-----------------------------------------------------------------------------------------------------------

Sub clear_all()

Dim lastvalued_row As Long
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sheet1")
lastvalued_row = ws.Cells(Rows.Count, "I").End(xlUp).Row

Range("I15", "I" & lastvalued_row).Clear

End Sub

Completed Project - image 1 - student project