#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Itreration

Is there a standard way of handling something like
the following?

Function DeleteColumn(inputArray, ColumnNumber)
'. . .
If IsArray(ColumnNumber) Then
[Run the DeleteColumn function itself]
[on each column number in turn]
inputArray = arrOut
DeleteColumn = arrOut
Exit Function
End If
'. . .
End Function

I ended up creating a DeleteColumnAdjunct function
that is the same as the DeleteColumn function
except for name, and ran

Function DeleteColumn(inputArray, ColumnNumber)
'. . .
If IsArray(ColumnNumber) Then
For w = UBound(ColumnNumber) To LBound(ColumnNumber) Step -1
arrOut = DeleteColumnAdjunct(inputArray, ColumnNumber(w))
Next
inputArray = arrOut
DeleteColumn = arrOut
Exit Function
End If
'. . .

but can't help thinking I'm missing the forest for the trees.

Thanks,
Alan Beban
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Itreration

I may be dense but I'm not following. What is this deleting?

And if the two functions are the same except for name then couldn't you just
use recursion and have the function call itself ?

Tim


"Alan Beban" wrote in message
...
Is there a standard way of handling something like
the following?

Function DeleteColumn(inputArray, ColumnNumber)
'. . .
If IsArray(ColumnNumber) Then
[Run the DeleteColumn function itself]
[on each column number in turn]
inputArray = arrOut
DeleteColumn = arrOut
Exit Function
End If
'. . .
End Function

I ended up creating a DeleteColumnAdjunct function
that is the same as the DeleteColumn function
except for name, and ran

Function DeleteColumn(inputArray, ColumnNumber)
'. . .
If IsArray(ColumnNumber) Then
For w = UBound(ColumnNumber) To LBound(ColumnNumber) Step -1
arrOut = DeleteColumnAdjunct(inputArray, ColumnNumber(w))
Next
inputArray = arrOut
DeleteColumn = arrOut
Exit Function
End If
'. . .

but can't help thinking I'm missing the forest for the trees.

Thanks,
Alan Beban



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Itreration

Tim Williams wrote:
I may be dense but I'm not following. What is this deleting?

And if the two functions are the same except for name then couldn't you just
use recursion and have the function call itself ?

Tim

Thanks for replying. The function is removing a column, as indicated by
ColumnNumber, from the array that is input to the function; I left out
all the code except the relevant snippet.

What code snippet are you suggesting for "use recursion and have the
function call itself"?

Thanks again,
Alan Beban

"Alan Beban" wrote in message
...

Is there a standard way of handling something like
the following?

Function DeleteColumn(inputArray, ColumnNumber)
'. . .
If IsArray(ColumnNumber) Then
[Run the DeleteColumn function itself]
[on each column number in turn]
inputArray = arrOut
DeleteColumn = arrOut
Exit Function
End If
'. . .
End Function

I ended up creating a DeleteColumnAdjunct function
that is the same as the DeleteColumn function
except for name, and ran

Function DeleteColumn(inputArray, ColumnNumber)
'. . .
If IsArray(ColumnNumber) Then
For w = UBound(ColumnNumber) To LBound(ColumnNumber) Step -1
arrOut = DeleteColumnAdjunct(inputArray, ColumnNumber(w))
Next
inputArray = arrOut
DeleteColumn = arrOut
Exit Function
End If
'. . .

but can't help thinking I'm missing the forest for the trees.

Thanks,
Alan Beban




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Itreration

Sorry. My previous response might have been too cryptic. When a single
number is input as the ColumnNumber parameter, the function (90% of
which is omitted from my original post) deletes from the input array the
specified column and returns the deleted version. In that case it skips
the below snippet because IsArray returns False. But if the input
ColumnNumber parameter is an array of numbers, the code is to delete all
the columns specified in that array of column numbers.

Thanks again.
Alan Beban

Tim Williams wrote:
I may be dense but I'm not following. What is this deleting?

And if the two functions are the same except for name then couldn't you just
use recursion and have the function call itself ?

Tim


"Alan Beban" wrote in message
...

Is there a standard way of handling something like
the following?

Function DeleteColumn(inputArray, ColumnNumber)
'. . .
If IsArray(ColumnNumber) Then
[Run the DeleteColumn function itself]
[on each column number in turn]
inputArray = arrOut
DeleteColumn = arrOut
Exit Function
End If
'. . .
End Function

I ended up creating a DeleteColumnAdjunct function
that is the same as the DeleteColumn function
except for name, and ran

Function DeleteColumn(inputArray, ColumnNumber)
'. . .
If IsArray(ColumnNumber) Then
For w = UBound(ColumnNumber) To LBound(ColumnNumber) Step -1
arrOut = DeleteColumnAdjunct(inputArray, ColumnNumber(w))
Next
inputArray = arrOut
DeleteColumn = arrOut
Exit Function
End If
'. . .

but can't help thinking I'm missing the forest for the trees.

Thanks,
Alan Beban




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



All times are GMT +1. The time now is 10:23 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"