PC Review


Reply
Thread Tools Rate Thread

Copy a range into an array

 
 
=?Utf-8?B?Um9iZXJ0?=
Guest
Posts: n/a
 
      23rd Mar 2007
I have a range ("B3:B23") in worsheet "Ranges" and I need to loop thru this
range and copy the values into an array.

Many Thanks
--
Robert Hill

 
Reply With Quote
 
 
 
 
WhytheQ
Guest
Posts: n/a
 
      23rd Mar 2007
hopefully this'll work:

Dim myArray()
Erase myArray 'incase it's already full
myArray =
Application.Transpose(ThisWorkbook.Sheets("Ranges").Range("B3:B23"))

Rgds
J


On Mar 23, 2:55 pm, Robert <rhill...@hotmail.com> wrote:
> I have a range ("B3:B23") in worsheet "Ranges" and I need to loop thru this
> range and copy the values into an array.
>
> Many Thanks
> --
> Robert Hill



 
Reply With Quote
 
=?Utf-8?B?Um9iZXJ0?=
Guest
Posts: n/a
 
      23rd Mar 2007
Thank You. Worked great.
--
Robert Hill



"WhytheQ" wrote:

> hopefully this'll work:
>
> Dim myArray()
> Erase myArray 'incase it's already full
> myArray =
> Application.Transpose(ThisWorkbook.Sheets("Ranges").Range("B3:B23"))
>
> Rgds
> J
>
>
> On Mar 23, 2:55 pm, Robert <rhill...@hotmail.com> wrote:
> > I have a range ("B3:B23") in worsheet "Ranges" and I need to loop thru this
> > range and copy the values into an array.
> >
> > Many Thanks
> > --
> > Robert Hill

>
>
>

 
Reply With Quote
 
asım şenyuva
Guest
Posts: n/a
 
      10th Jul 2008

public vois CopySelectedItemsOneByOne();
// Get Row Count in Range
int lastRow = (LExcel.ActiveSheet as
Excel.Worksheet).UsedRange.Rows.Count;

//Get Col Count in Range
int lastCol = (LExcel.ActiveSheet as
Excel.Worksheet).UsedRange.Columns.Count;

object value;
//object value2;

Excel.Range excelCell = (Excel.Range)ThisAddIn.ExcelApp.Selection;

object obj = ThisAddIn.ExcelApp.Selection;

if (obj is Excel.Range)
{
Excel.Range selection = (Excel.Range)obj;

//value2 = (selection.Cells[lastRow, lastCol] as Excel.Range);

// Get Address Of Last Cell
string x = (selection.Cells[lastRow, lastCol] as
Excel.Range).Cells.get_Address(false, false,
Microsoft.Office.Interop.Excel.XlReferenceStyle.xlA1, null, null);


// Get Values of all cells
for (int c = 1; c <= lastCol; c++)
{
for (int r = 1; r <= lastRow; r++)
{
value = (selection.Cells[r, c] as Excel.Range).Value2;
if (value != null)
{
MessageBox.Show(value.ToString());
}
}
}


}

------------------------

"Robert" wrote:

> Thank You. Worked great.
> --
> Robert Hill
>
>
>
> "WhytheQ" wrote:
>
> > hopefully this'll work:
> >
> > Dim myArray()
> > Erase myArray 'incase it's already full
> > myArray =
> > Application.Transpose(ThisWorkbook.Sheets("Ranges").Range("B3:B23"))
> >
> > Rgds
> > J
> >
> >
> > On Mar 23, 2:55 pm, Robert <rhill...@hotmail.com> wrote:
> > > I have a range ("B3:B23") in worsheet "Ranges" and I need to loop thru this
> > > range and copy the values into an array.
> > >
> > > Many Thanks
> > > --
> > > Robert Hill

> >
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy array to range Stefi Microsoft Excel Programming 2 18th May 2009 08:37 AM
Fast copy method of sub array (=array range) possible? Thomas Lebrecht Microsoft VB .NET 0 19th Mar 2009 08:49 AM
Using an Array to Speed-Up Range Copy JingleRock Microsoft Excel Programming 4 15th Sep 2007 08:17 AM
copy one array formula to an array range =?Utf-8?B?Z3VlZGo1NA==?= Microsoft Excel Programming 2 29th Oct 2006 07:38 PM
How Can I copy all value of the array into the range? sjoo Microsoft Excel Programming 0 8th Aug 2003 07:30 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:19 AM.