Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / September 2007

Tip: Looking for answers? Try searching our database.

array data to cells

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
anduare2 - 12 Sep 2007 23:46 GMT
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 - 13 Sep 2007 02:24 GMT
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.

> This loads 26 items from a column into myarray1 (thanks to the posts for
> that).
[quoted text clipped - 23 lines]
>
> Thanks

Signature

Dave Peterson

anduare2 - 14 Sep 2007 14:24 GMT
Fantastic, this really cleaned up my sad little program so much.  So simple
and straight to the point.  Very much appreciated.

> Dim i as Long
> dim wks as worksheet
[quoted text clipped - 45 lines]
> >
> > Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.