Hello,
I would like to delete a row from an array that I have filled from a range. Is there a way to do this or must I copy the rows I want to a 'temporary' array? Please note this array has multiple columns!
Delete row in Array
-
-
-
Re: Delete row in Array
Yep, you need to go via a temporary array.
TJ
-
Re: Delete row in Array
Thanks TJ... I was hoping there was a function
To declare my temp array, I know the UBOUND function will tell me how many rows, what will tell me how many columns I need?
-
Re: Delete row in Array
Hi Lydia,
What do you have in mind when you say 'delete'?
Are you looking to fill the array with zero values or to actually change the bounds of the array?
The former could be done like this:[vba]Sub Array_Test()
Dim UserRange As Range
Dim QuoteDetailArray As Variant
Dim iCol As Integer
With ActiveSheet
' Define the range
Set UserRange = ActiveSheet.Range("OrderItems")
' Move the range to an array
QuoteDetailArray = UserRange
For iCol = 1 To UBound(QuoteDetailArray, 2)
QuoteDetailArray(3, iCol) = 0
Next iCol
' Return array back to spreadsheet
UserRange = QuoteDetailArray
End With
End Sub[/vba] -
Re: Delete row in Array
The number of columns can be found also with UBound, as per Richie's code:
[vba]
For iCol = 1 To UBound(QuoteDetailArray, 2)
[/vba]TJ
-
-
Re: Delete row in Array
Thanks for your responses! I wanted to actually change the bounds of the array. It works by moving to another 'temp' array and then back.
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!