hi all,
I am learning how to write a Function.
I have created a sub named Testing with twenty lines of codes in Excel 2002.
Since some of the codes contains a few lines of duplicate IF and Else statements,
I decided to make use of Function.
Here is the code:
Private Function finding(ByVal x As Double, ByVal whereToPasteAABB As Double) As Integer
Dim isSame As Variant
If (Trim(Worksheets("RAW_Data").Cells(x, 1).Value) = Trim(Worksheets("arbitrary").Cells(whereToPasteAABB - 1, 1).Value)) Then
isSame = isSame + 1
ElseIf (Trim(Worksheets("RAW_Data").Cells(x, 1).Value) = Trim(Worksheets("arbitrary").Cells(whereToPasteAABB - 2, 1).Value)) Then
isSame = isSame + 1
finding = isSame
End Function
Sub testing()
Dim isSame As Variable
isSame = finding(1, 5)
MsgBox isSame
End sub
Since this is my first time writing a Function, I am not sure if
there's anything in the codes that I need to alter or change in the Function.
Please give me some advice and help
Thank you
Kitty
Bookmarks