My First Excel Macro
Nothing to write home to mom about, but I have gone from programming in C++ to Java to VBA. My first VBA script does very little but it saved me a lot of time
Dim x As Integer
x = 1
For Each oRow In Sheet1.Range("A:A")
For Each nRow In Sheet2.Range("A1:A244")
If (oRow = nRow) Then
Sheet3.Cells(x, 1) = oRow
x = x + 1
End If
Next nRow
Next oRow
Dim row
End Sub
Basically checks if the the elements from Range A:A (i.e. all the elements in the column) in Sheet 1 were repeated in A2:A244 in Sheet 2. I could have exported the sheet into a csv file and written a perl script or something in java to do it. But it's always fun to experiment with a new language.
Dim x As Integer
x = 1
For Each oRow In Sheet1.Range("A:A")
For Each nRow In Sheet2.Range("A1:A244")
If (oRow = nRow) Then
Sheet3.Cells(x, 1) = oRow
x = x + 1
End If
Next nRow
Next oRow
Dim row
End Sub
Basically checks if the the elements from Range A:A (i.e. all the elements in the column) in Sheet 1 were repeated in A2:A244 in Sheet 2. I could have exported the sheet into a csv file and written a perl script or something in java to do it. But it's always fun to experiment with a new language.
Labels: computer, Programming
2 Comments:
Hey man, great to see you are "active" (sort of) on blogging again!
VBA does help solve a lot of mundane and repetitive work on Excel. I actually learn a major part of that from my class at MSF class in IIT.
Check out "VBA for Modelers" by Albright. I think it's a great book for learning VBA :)
Keep blogging man!
It's good to be back :)
(Takes a bow)
Post a Comment
<< Home