Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default calling function form within sub

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
calling a function in a worksheet from a user form steve Excel Programming 1 January 19th 06 10:00 PM
How to pass a variable from Form back to calling procedure John[_111_] Excel Programming 4 August 21st 05 03:54 PM
Calling the Print Form Derek from Belgium Excel Programming 2 May 23rd 05 02:12 PM
Calling Com addin from form button on sheet? Robin Hammond[_2_] Excel Programming 8 January 8th 05 03:03 AM
Calling variable from user form Geraldon Excel Programming 2 February 9th 04 03:18 PM


All times are GMT +1. The time now is 06:31 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"