Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

delete a row.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RobcPettit@yahoo.co.uk - 20 Mar 2006 13:58 GMT
Hi, if Ive assigned values from a1:a20 in vba to 'myarray', and I want
to delete the first row/value so value 2 now becomes 1 etc, what is the
best way to do this.
Regards Robert
Chip Pearson - 20 Mar 2006 14:29 GMT
Use code like

Rows(1).Delete
or
Dim MyRange As Range
Set MyRange = Range("MyRange")
Range("MyRange")(1, 1).EntireRow.Delete

Signature

Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

> Hi, if Ive assigned values from a1:a20 in vba to 'myarray', and
> I want
> to delete the first row/value so value 2 now becomes 1 etc,
> what is the
> best way to do this.
> Regards Robert
RobcPettit@yahoo.co.uk - 20 Mar 2006 14:47 GMT
Sorry, didnt word that very well, I meant delete the row in the array
itself.
Regards Robert
Tom Ogilvy - 20 Mar 2006 17:10 GMT
Sub ABC()
Dim myarray As Variant
myarray = Range("MyRange").Value
' convert to a 1D array
myarray = _
 Application.Transpose(myarray)
For i = LBound(myarray) To UBound(myarray) - 1
myarray(i) = myarray(i + 1)
Next
ReDim Preserve myarray(1 To UBound(myarray) - 1)
For i = LBound(myarray) To UBound(myarray)
 Debug.Print i, myarray(i)
Next
End Sub

Signature

Regards,
Tom Ogilvy

> Sorry, didnt word that very well, I meant delete the row in the array
> itself.
> Regards Robert
Tom Ogilvy - 20 Mar 2006 17:12 GMT
Sub ABC()
Dim myarray As Variant
myarray = Range("MyRange").Value
' convert to a 1D array
myarray = _
 Application.Transpose(myarray)
For i = LBound(myarray) To UBound(myarray) - 1
myarray(i) = myarray(i + 1)
Next
ReDim Preserve myarray(1 To UBound(myarray) - 1)
For i = LBound(myarray) To UBound(myarray)
 Debug.Print i, myarray(i)
Next
End Sub

Signature

Regards,
Tom Ogilvy

> Sorry, didnt word that very well, I meant delete the row in the array
> itself.
> Regards Robert
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.