LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 213
Default Using Array's

In the code below I have an Array setup (or so I think), How do I use it to
delete the rows that have been copied?
What I have fails with Error 9, subscript out of range.

'======
Sub test1()
sUserPart = InputBox(("Enter a Value!"), Default:="8769")
With Sheets("Sheet1")
Sh1LastRow = .Cells(Rows.Count, "B").End(xlUp).Row
Sh1LastRow = Sh1LastRow + 1
Set Sh1Range = .Range("B1:B" & Sh1LastRow)
End With
sFound = False
For Each sh1cell In Sh1Range
If sh1cell.Value Like "*" & sUserPart & "*" Then
sFound = True
Application.Goto
Reference:=Worksheets("Sheet1").Range(sh1cell.Addr ess), _
Scroll:=True
vSelection = MsgBox("Use this selection? " & sh1cell.Value & "
", vbYesNoCancel)
If vSelection = vbYes Then
sFound = True
With Sheets("Sheet2")
sh2lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
Set Sh2Range = .Range("A1:A" & sh2lastrow)
If Sheets("Sheet2").Range("A" & sh2lastrow).Value < ""
Then
sh2lastrow = sh2lastrow + 1
End If
End With
sh1cell.EntireRow.Copy
Destination:=Sheets("Sheet2").Range("A" & sh2lastrow)
Dim N As Long
Dim CellArray() As Variant
N = N + 1
ReDim Preserve CellArray(1 To N)
CellArray(N) = sh1cell.Address
End If
ElseIf vSelection = vbNo Then
sFound = False
ElseIf vSelection = vbCancel Then
sFound = False
GoTo EndIt
End If
Next sh1cell
If sFound = False Then
MsgBox "No Match Found!"
End If
If N 0 Then
Sheets(CellArray()).EntireRow.Delete 'reports error 9
Selection.Delete
End If
EndIt:
Range("A1").Activate
End Sub
'======
--
Regards

VBA.Newb.Confused
XP Pro
Office 2007

 
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
Array's, Calculations and Results smokiesandwine Excel Programming 4 October 19th 06 02:02 AM
Help with array's dgo Excel Worksheet Functions 2 June 28th 06 03:15 PM
How do I return location (not value)of an Excel array's max value Doug Excel Programming 2 August 30th 05 03:08 PM
Selecting & Displaying An Array's Contents Scott Excel Programming 0 February 20th 04 04:21 PM
!!! Newbie VBA question about array's and listbox !!! Tom Ogilvy Excel Programming 0 September 8th 03 01:17 PM


All times are GMT +1. The time now is 10:20 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"