PC Review


Reply
Thread Tools Rate Thread

array data to cells

 
 
=?Utf-8?B?YW5kdWFyZTI=?=
Guest
Posts: n/a
 
      12th Sep 2007
This loads 26 items from a column into myarray1 (thanks to the posts for
that).

Dim i As Integer
i = 1
For i = 1 To 26

Dim myarray1()
Erase myarray1
myarray1 =
Application.Transpose(ThisWorkbook.Sheets("Dates").Range("b5:b30"))

My "for next" section adds a page, names if from a similar array using this
function (ActiveSheet.Name = myarrayx(i)), sets margins, print area and then
goes on to add the next 25 pages.

What I need, is to enter the myarray1(i) data (also 26 items) into cell b14
on each page as they are created and formatted in the for next routine. What
is the best (ie most simple code) function to use to accomplish this.

The data I put in my array are dates and I want to retreive them as dates.
If I need to redefine my array for dates please let me know. As you can tell
I am not nearly as accomplished in macro/vba as most people in these forums.

Any suggestions are welcome, if more info is needed from me just ask.

Thanks
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      13th Sep 2007
Dim i as Long
dim wks as worksheet
dim myNames(1 to 26) as string
dim myDates(1 to 26) as date

'populate your arrays

for i = lbound(mynames) to ubound(mynames)
set wks = worksheets.add
wks.name = mynames(i)
with wks.range("B14")
.numberformat = "mm/dd/yyyy"
.value = mydates(i)
end with
next i

(Untested, uncompiled)

Instead of using variables like myArrayX and myArray1, you may find it easier if
you use variable names that are mnemonically significant--that mean something
when you're reading/writing the code.



anduare2 wrote:
>
> This loads 26 items from a column into myarray1 (thanks to the posts for
> that).
>
> Dim i As Integer
> i = 1
> For i = 1 To 26
>
> Dim myarray1()
> Erase myarray1
> myarray1 =
> Application.Transpose(ThisWorkbook.Sheets("Dates").Range("b5:b30"))
>
> My "for next" section adds a page, names if from a similar array using this
> function (ActiveSheet.Name = myarrayx(i)), sets margins, print area and then
> goes on to add the next 25 pages.
>
> What I need, is to enter the myarray1(i) data (also 26 items) into cell b14
> on each page as they are created and formatted in the for next routine. What
> is the best (ie most simple code) function to use to accomplish this.
>
> The data I put in my array are dates and I want to retreive them as dates.
> If I need to redefine my array for dates please let me know. As you can tell
> I am not nearly as accomplished in macro/vba as most people in these forums.
>
> Any suggestions are welcome, if more info is needed from me just ask.
>
> Thanks


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?YW5kdWFyZTI=?=
Guest
Posts: n/a
 
      14th Sep 2007
Fantastic, this really cleaned up my sad little program so much. So simple
and straight to the point. Very much appreciated.

"Dave Peterson" wrote:

> Dim i as Long
> dim wks as worksheet
> dim myNames(1 to 26) as string
> dim myDates(1 to 26) as date
>
> 'populate your arrays
>
> for i = lbound(mynames) to ubound(mynames)
> set wks = worksheets.add
> wks.name = mynames(i)
> with wks.range("B14")
> .numberformat = "mm/dd/yyyy"
> .value = mydates(i)
> end with
> next i
>
> (Untested, uncompiled)
>
> Instead of using variables like myArrayX and myArray1, you may find it easier if
> you use variable names that are mnemonically significant--that mean something
> when you're reading/writing the code.
>
>
>
> anduare2 wrote:
> >
> > This loads 26 items from a column into myarray1 (thanks to the posts for
> > that).
> >
> > Dim i As Integer
> > i = 1
> > For i = 1 To 26
> >
> > Dim myarray1()
> > Erase myarray1
> > myarray1 =
> > Application.Transpose(ThisWorkbook.Sheets("Dates").Range("b5:b30"))
> >
> > My "for next" section adds a page, names if from a similar array using this
> > function (ActiveSheet.Name = myarrayx(i)), sets margins, print area and then
> > goes on to add the next 25 pages.
> >
> > What I need, is to enter the myarray1(i) data (also 26 items) into cell b14
> > on each page as they are created and formatted in the for next routine. What
> > is the best (ie most simple code) function to use to accomplish this.
> >
> > The data I put in my array are dates and I want to retreive them as dates.
> > If I need to redefine my array for dates please let me know. As you can tell
> > I am not nearly as accomplished in macro/vba as most people in these forums.
> >
> > Any suggestions are welcome, if more info is needed from me just ask.
> >
> > Thanks

>
> --
>
> Dave Peterson
>

 
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
Need data result in last cell of array that contains blank cells smesurfer Microsoft Excel Misc 2 8th Feb 2010 10:51 PM
combining cells and array from different sheets into an array to pass to IRR() danyates77@yahoo.com Microsoft Excel Misc 3 11th Sep 2006 07:17 AM
Checking data in each cells of an array cyzax7 via OfficeKB.com Microsoft Excel Programming 9 24th Jun 2006 10:39 PM
Copy Data From Cells To Array MarcL via OfficeKB.com Microsoft Excel Programming 3 8th Mar 2006 02:27 PM
Pull data from one Array based on data in first Array kieran Microsoft VB .NET 1 5th Oct 2005 07:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:32 PM.