ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Deleting Last values in an array (https://www.excelbanter.com/excel-programming/353476-deleting-last-values-array.html)

gti_jobert[_19_]

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


Bob Phillips[_6_]

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




Bob Phillips[_6_]

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




gti_jobert[_22_]

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



All times are GMT +1. The time now is 02:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com