Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deleting Last values in an array


Hi all,

I populate an array with data like so;


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


Private Sub cmdMCDT_Click()

Dim i%

Static Counter As Long
Counter = Counter + 1

ReDim Preserve ary(1 To 3, 1 To 3, 1 To Counter)

For i = 1 To 3
ary(1, i, Counter) = MachineNumber
ary(2, i, Counter) = Controls("lblDTCode" & i).Caption
ary(3, i, Counter) = Controls("lblDTDuration" & i).Caption
Next i

End Sub

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


The problem is that I want to be able to delete the last entry (or how
ever many entries) from the array and then overwrite the array with a
new set of data.

Anyone know how I would go about doing this? All help appreciated!


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=513104

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Deleting Last values in an array

ary(UBound(ary,1),Counter) = new_value

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"gti_jobert" wrote
in message ...

Hi all,

I populate an array with data like so;


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


Private Sub cmdMCDT_Click()

Dim i%

Static Counter As Long
Counter = Counter + 1

ReDim Preserve ary(1 To 3, 1 To 3, 1 To Counter)

For i = 1 To 3
ary(1, i, Counter) = MachineNumber
ary(2, i, Counter) = Controls("lblDTCode" & i).Caption
ary(3, i, Counter) = Controls("lblDTDuration" & i).Caption
Next i

End Sub

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


The problem is that I want to be able to delete the last entry (or how
ever many entries) from the array and then overwrite the array with a
new set of data.

Anyone know how I would go about doing this? All help appreciated!


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile:

http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=513104



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Deleting Last values in an array

That should have been

ary(UBound(ary, 1), 1, Counter) = 1

--

HTH

Bob Phillips

(remove nothere from the email address if mailing direct)

"gti_jobert" wrote
in message ...

Hi all,

I populate an array with data like so;


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


Private Sub cmdMCDT_Click()

Dim i%

Static Counter As Long
Counter = Counter + 1

ReDim Preserve ary(1 To 3, 1 To 3, 1 To Counter)

For i = 1 To 3
ary(1, i, Counter) = MachineNumber
ary(2, i, Counter) = Controls("lblDTCode" & i).Caption
ary(3, i, Counter) = Controls("lblDTDuration" & i).Caption
Next i

End Sub

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


The problem is that I want to be able to delete the last entry (or how
ever many entries) from the array and then overwrite the array with a
new set of data.

Anyone know how I would go about doing this? All help appreciated!


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile:

http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=513104



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Deleting Last values in an array


Thanks again for your help bob, always appreciated!! Think I've got it
working now, got some modding of code to before it fully functions.


--
gti_jobert
------------------------------------------------------------------------
gti_jobert's Profile: http://www.excelforum.com/member.php...o&userid=30634
View this thread: http://www.excelforum.com/showthread...hreadid=513104

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
Deleting blank values from an array chemdude77 Excel Programming 2 January 6th 06 07:31 PM
deleting values in a worksheet without deleting the formulas patti Excel Worksheet Functions 1 October 28th 05 09:49 PM
Deleting blank values from an array Rich J[_2_] Excel Programming 6 June 1st 05 11:28 PM
Deleting element in Array ExcelMonkey[_190_] Excel Programming 3 March 28th 05 02:47 AM
deleting array element michael Excel Programming 0 December 18th 03 08:55 PM


All times are GMT +1. The time now is 09:45 PM.

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"