View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Function exists prematurely

I don't think that is it, at least it is not in my testing. The code defines
a variable called columns. Now that may not be a practice that you or I
would endorse, but it does seem to 'work' as he thinks. It certainly
wouldn't hurt though if he changed the name and tried again.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"NickHK" wrote in message
...
brain,
How do think this routine works ?
Private Sub CountAllcolumnsOnWS()
MsgBox Columns.Count
End Sub

Hint: How many columns do you think Excel is trying to delete ?

NickHK

"brain" wrote in

message
...

I'm having a problem with the following function. For some reason, the
function returns before the first MsgBox call. It succesfully deletes
the column, but it exits right after. Any help?

Code:
--------------------

Sub main()
Dim numRates As Integer
Dim numDates As Integer

Const RateOffset As Integer = 5
Const DateOffset As Integer = 3

Dim columns As Range
Dim ratesRange As Range

numRates = Range("IntTimeSeriesRates").Value
numDates = Range("IntTimeSeriesDates").Value

Set columns = Range(Cells(RateOffset, DateOffset + numDates - 1),

Cells(RateOffset + numDates, DateOffset + numDates - 1))
columns.Delete

MsgBox "Hello1"
Set columns = Range(Cells(RateOffset, DateOffset), Cells(RateOffset +

numRates, DateOffset))
columns.Insert shift:=xlToRight

MsgBox "Hello2"
End Sub

--------------------


--
brain
------------------------------------------------------------------------
brain's Profile:

http://www.excelforum.com/member.php...o&userid=32991
View this thread:

http://www.excelforum.com/showthread...hreadid=528185