View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 6,953
Default calling function form within sub

change it to

If isempty(ran(i, 2)) Then call swapRows(ran.Row(i),ran.Row(i+1))


or

If isempty(ran(i, 2)) Then swapRows ran.Row(i), ran.Row(i+1)

this is the syntax of VBA/VB.

--
Regards,
Tom Ogilvy



"Dirk" wrote:

All

I am trying to call a function form within a sub, but VBA doesn't
accept the swapRows function and asks for a =. Why?

Dirk

Function swapRows(areaSwap1 As Range, areaSwap2 As Range)
' a lot of code
End Function

Sub schedule()
Dim ran As Range
Dim num As Integer

Set ran = InputBox("select range including heading for columns",
Type:=8)
num = ran.Rows.Count
For i = 2 To num
If isempty(ran(i, 2)) Then swapRows(ran.Row(i),ran.Row(i+1))
Next i

End Sub