Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 23rd, 2004, 05:53 PM
Authorized User
 
Join Date: Jun 2004
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Populate cells with arrays

Hi:


I have >50 arrays with 30 elements each. On a sheet, it would look like a 50rows x 30columns table.
For now, I can live with the row loops. But, I really need a way so I can populate my columns (Ax:ADx) with my array elements without doing the column loops. What I have right now is a very simple column loop but hurts the performance really bad.

Range("A1").Activate
For i = 1 To 30
  ActiveCell.Value = Array1(i)
  ActiveCell.Next.Activate
Next i

Does anyone have a better solution?


Regards,
Adrian T
 
Old July 24th, 2004, 01:32 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 112
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You're hurting performance because you are selecting each cell in turn... Try something like this:

'Application.ScreenUpdating = False
For I = 1 To 30
    ActiveSheet.UsedRange.Columns("A").Cells(I).Value = Array1(I)
Next
'Application.ScreenUpdating = True

You can also increase performance by turning off screen redraws until your loop is finished.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Datagrid Cells Abbas C# 2005 1 October 12th, 2007 09:35 AM
Multidemmesional Arrays OR arrays gmoney060 Classic ASP Basics 3 November 1st, 2004 03:42 PM
Protecting Cells jacks Excel VBA 1 February 20th, 2004 11:55 AM
Cells MattLeek Excel VBA 2 December 12th, 2003 11:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.