Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I create a sub function

How do I create a function that is sent two variables. I want it be sen
a variable called i and another FinalRow. Then I want it to do it'
thing. I want to be able to call this function at anytime in my macr
by just typing FunctionName(i,FinalRow). Here what I want to b
included in my function

n = i
For n = i To FinalRow
If (Range("A" & n).Value) = "" And (Range("B" & n).Value) = 1 An
(Range("C" & n).Value) = 1 And (Range("D" & n).Value) = "" Then
Rows(n & ":" & n).Cut
Rows(i & ":" & i).Insert Shift:=xlDown
End If
Next n

Thank yo

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default How do I create a sub function

Function MyFunction(I As Integer, FinalRow As Integer) As String

Your code here
MyFunction = Result
End Function

But I think what you want is something else because a function is used for
returning a value.
What you might want is a Sub.

Public Sub MySub(I As Integer, FinalRow As Integer)
Your Code Here
End Sub

"atoth22 " wrote in message
...
How do I create a function that is sent two variables. I want it be sent
a variable called i and another FinalRow. Then I want it to do it's
thing. I want to be able to call this function at anytime in my macro
by just typing FunctionName(i,FinalRow). Here what I want to be
included in my function

n = i
For n = i To FinalRow
If (Range("A" & n).Value) = "" And (Range("B" & n).Value) = 1 And
(Range("C" & n).Value) = 1 And (Range("D" & n).Value) = "" Then
Rows(n & ":" & n).Cut
Rows(i & ":" & i).Insert Shift:=xlDown
End If
Next n

Thank you


---
Message posted from http://www.ExcelForum.com/



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
How to create function to look up the value TT Excel Discussion (Misc queries) 0 April 27th 09 07:54 AM
How to create an IF function Cindygirl Excel Worksheet Functions 1 March 25th 09 09:56 PM
not sure how to create this function dilbert16588 Excel Worksheet Functions 1 March 8th 08 05:24 PM
Trying to create a certain function chas Excel Worksheet Functions 3 December 26th 06 09:02 PM
Create new function [email protected] Excel Discussion (Misc queries) 1 March 14th 06 04:47 PM


All times are GMT +1. The time now is 09:34 AM.

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

About Us

"It's about Microsoft Excel"