Subroutine and function!! help!!!

bukikids

New Member
Joined
Jul 20, 2011
Messages
5
Im new to programming and excel. My code should include one subroutine and one function, but i dont know how to add the function.

please help me thanks!!:)

121rc.jpg


here is my code:
Sub findServiceDescription()

Dim user As String
Dim Service As String
Dim rowCounter As Integer
Dim BankingDesc As String

rowCounter = 1
serviceNumber = Cells(rowCounter, 1).Value

user = InputBox("Please enter your service")


Do While user <> serviceNumber
rowCounter = rowCounter + 1
serviceNumber = Cells(rowCounter, 1).Value


' if banking desc is empty, output service not found
BankingDesc = Cells(rowCounter, 2).Value

If BankingDesc = "" Then
MsgBox "No Service Found"
Exit Do

End If
Loop

If BankingDesc <> "" Then
MsgBox "Banking Service: " & BankingDesc
End If
End Sub
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
In VBA, click Insert > Module. The double-click the module name and go Insert > Procedure > Function. Finally insert your code in the function's code window.
 
Upvote 0
In VBA, click Insert > Module. The double-click the module name and go Insert > Procedure > Function. Finally insert your code in the function's code window.


thanks alot, but i stil dont know how to change the code to make the function and subroutine call each other.:(

please help me. thank you!:)
 
Upvote 0
You haven't shown us the function, explained what it does, or indicated where or why you need to use it. There's no function call in your subroutine as far as I can see, nor is there a function defined in the code you've posted.

Does the subroutine work okay as it stands?

When you say your code should include a function, what makes you say that?
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,547
Messages
6,179,436
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top