LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Create an Array to fill a Range

I'm trying to create a workbook of labels using an array to fill a range of
cells A4 to P75 from a user input box or boxes. The order should be A4:A75
through to P4:P75. i.e. A4 = 1 to A75 = 72 etc. I would like to expand the
user input for text as well as numerical data, where the text element would
be fixed and the numerical data would be sequential. e.g. 7F/01-001

The following sub (borrowed from Excel 2000 Power Programming with VBA)
works but in rows instead of cols.

My VBA ability is very, very rusty & I could use some help.

TIA

Sub ArrayFillRange()

' Fill a range by transferring an array
Dim TempArray() As Integer
Dim TheArray As Range

' Get the dimensions
CellsDown = Val(InputBox("How many cells down?"))
CellsAcross = Val(InputBox("How many cells across?"))

' Redimension temp array
ReDim TempArray(1 To CellsDown, 1 To CellsAcross)

' Set worksheet range
Set TheRange = ActiveCell.Range(Cells(1, 1), Cells(CellsDown,
CellsAcross))

' Fill the temp array
Currval = 0
Application.ScreenUpdating = False
For i = 1 To CellsDown
For j = 1 To CellsAcross
TempArray(i, j) = Currval + 1
Currval = Currval + 1
Next j
Next i

' Transfer temp array to worksheet
TheRange.Value = TempArray

End Sub
 
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
how do i fill an array? tia JasonK[_2_] Excel Programming 7 September 19th 06 07:31 PM
create a fill in template to tab to fill in cells Excel-erator Excel Discussion (Misc queries) 2 July 6th 05 09:57 PM
Create Array From Values in range Tony Di Stasi[_2_] Excel Programming 2 February 27th 04 09:40 PM
Create and Array formula using range names Carmen A Excel Programming 0 August 22nd 03 09:37 AM
Create and Array formula using range names Huuh Excel Programming 6 August 18th 03 04:48 PM


All times are GMT +1. The time now is 02:45 AM.

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

About Us

"It's about Microsoft Excel"