Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Assing a dynamic range to an array

I have a sheet populated with a changing list of names. I am trying to
create code which will assign those names to a dynamic array.
The code looks for the cell with the value "Mechanics:" and then I
want it to assign the groups of mechanics names in the changing range
of names directly below the found cell to an array.

I have the following code snippet which I am having troubles with:

With Worksheets("Index")
Set c = .Cells.Find("Mechanics:", LookIn:=xlValues)
If Not c Is Nothing Then
MechNameStart = c.Offset(1, 0)
MechNameEnd = MechNameStart.End(xlDown)
End If
End With

I am getting Run-time error '424': Object required.
What I would like to do then is assign the entire range from the start
(MechNameStart) to the end (MechNameEnd) to an array.

Thanks in advance for any assistance...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Assing a dynamic range to an array

Sorry, didn't mean to call it Assing (Assigning) :p

On Jan 23, 5:55*pm, " wrote:
I have a sheet populated with a changing list of names. I am trying to
create code which will assign those names to a dynamic array.
The code looks for the cell with the value "Mechanics:" and then I
want it to assign the groups of mechanics names in the changing range
of names directly below the found cell to an array.

I have the following code snippet which I am having troubles with:

* * With Worksheets("Index")
* * * * * * * * Set c = .Cells.Find("Mechanics:", LookIn:=xlValues)
* * * * * * * * If Not c Is Nothing Then
* * * * * * * * * * MechNameStart = c.Offset(1, 0)
* * * * * * * * * * MechNameEnd = MechNameStart.End(xlDown)
* * * * * * * * End If
* * End With

I am getting Run-time error '424': Object required.
What I would like to do then is assign the entire range from the start
(MechNameStart) to the end (MechNameEnd) to an array.

Thanks in advance for any assistance...


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default Assing a dynamic range to an array

With Worksheets("Index")
Set c = .Cells.Find("Mechanics:", LookIn:=xlValues)
If Not c Is Nothing Then
MechNameStart = c.Offset(1, 0)
MechNameEnd = MechNameStart.End(xlDown)
End If
MyArray = Application.Transpose(c.Resize(MechNameEnd.Row -
MechNameStart + 1))
End With


--
__________________________________
HTH

Bob

wrote in message
...
I have a sheet populated with a changing list of names. I am trying to
create code which will assign those names to a dynamic array.
The code looks for the cell with the value "Mechanics:" and then I
want it to assign the groups of mechanics names in the changing range
of names directly below the found cell to an array.

I have the following code snippet which I am having troubles with:

With Worksheets("Index")
Set c = .Cells.Find("Mechanics:", LookIn:=xlValues)
If Not c Is Nothing Then
MechNameStart = c.Offset(1, 0)
MechNameEnd = MechNameStart.End(xlDown)
End If
End With

I am getting Run-time error '424': Object required.
What I would like to do then is assign the entire range from the start
(MechNameStart) to the end (MechNameEnd) to an array.

Thanks in advance for any assistance...



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Assing a dynamic range to an array

Bob missed a couple of typos in your original code (missing "Set" statements).

Option Explicit
Sub testme()

Dim c As Range
Dim MechNameStart As Range
Dim MechNameEnd As Range
Dim myArray As Variant

With Worksheets("Index")
Set c = .Cells.Find("Mechanics:", LookIn:=xlValues)
If Not c Is Nothing Then
Set MechNameStart = c.Offset(1, 0)
Set MechNameEnd = MechNameStart.End(xlDown)
End If
myArray = Application.Transpose(MechNameStart _
.Resize(MechNameEnd.Row - MechNameStart.Row + 1))
End With
End Sub

And I bet you wanted to start with MechNameStart.

Bob used application.transpose() to make the array a one dimensional array.

If Bob had used:
myArray = MechNameStart.Resize(MechNameEnd.Row - MechNameStart.Row + 1)

Then myArray would have had two dimensions (x Rows by 1 column).

Bob Phillips wrote:

With Worksheets("Index")
Set c = .Cells.Find("Mechanics:", LookIn:=xlValues)
If Not c Is Nothing Then
MechNameStart = c.Offset(1, 0)
MechNameEnd = MechNameStart.End(xlDown)
End If
MyArray = Application.Transpose(c.Resize(MechNameEnd.Row -
MechNameStart + 1))
End With

--
__________________________________
HTH

Bob

wrote in message
...
I have a sheet populated with a changing list of names. I am trying to
create code which will assign those names to a dynamic array.
The code looks for the cell with the value "Mechanics:" and then I
want it to assign the groups of mechanics names in the changing range
of names directly below the found cell to an array.

I have the following code snippet which I am having troubles with:

With Worksheets("Index")
Set c = .Cells.Find("Mechanics:", LookIn:=xlValues)
If Not c Is Nothing Then
MechNameStart = c.Offset(1, 0)
MechNameEnd = MechNameStart.End(xlDown)
End If
End With

I am getting Run-time error '424': Object required.
What I would like to do then is assign the entire range from the start
(MechNameStart) to the end (MechNameEnd) to an array.

Thanks in advance for any assistance...


--

Dave Peterson
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
Assing a Name to a Range ryguy7272 Excel Programming 5 November 20th 08 04:27 PM
Assigning a Range to a dynamic array Tommy[_4_] Excel Programming 1 February 20th 08 05:07 PM
creating a dynamic range based on criteria, within a dynamic range, and passing it to a function [email protected] Excel Programming 0 October 9th 07 05:22 PM
array formula with a dynamic range. Dave Excel Worksheet Functions 2 June 26th 06 06:16 AM
Subscript out range error when redimensioning dynamic array Crazy Cat Excel Programming 1 January 12th 06 06:25 AM


All times are GMT +1. The time now is 12:41 PM.

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

About Us

"It's about Microsoft Excel"