Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default delete a row.

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default delete a row.

Use code like

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


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


wrote in message
oups.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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default delete a row.

Sorry, didnt word that very well, I meant delete the row in the array
itself.
Regards Robert

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default delete a row.

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

--
Regards,
Tom Ogilvy


" wrote:

Sorry, didnt word that very well, I meant delete the row in the array
itself.
Regards Robert


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default delete a row.

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

--
Regards,
Tom Ogilvy


" wrote:

Sorry, didnt word that very well, I meant delete the row in the array
itself.
Regards Robert


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
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 1 June 22nd 05 01:12 AM
Macro to delete sheets and saves remaining file does not properly delete module pherrero Excel Programming 0 June 21st 05 05:11 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:53 PM
Macro to delete sheets and saves remaining file does not properly delete module bhawane Excel Programming 0 June 21st 05 04:20 PM
Delete every 3rd row, then delete rows 2-7, move info f/every 2nd row up one to the end and delete the row below Annette[_4_] Excel Programming 2 September 21st 04 02:40 PM


All times are GMT +1. The time now is 11:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"