LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Looping through Sheets and passing values to an Array

This macro loops through all the worksheets in a workbook, placing th
value of cell "a1" into an array, then inserts a new page at the star
of the workbook, and inserts the value in successive cells from cel
a2.

Sub loop_and_list()
Dim myarray()
n = 0

For Each ws In ActiveWorkbook.Worksheets
ReDim Preserve myarray(n)
myarray(n) = ws.Range("a1").Value
n = 1 + n
Next

Sheets.Add befo=Sheets(1)
Sheets(1).Select
Range("a2").Select

For n = LBound(myarray) To UBound(myarray)
ActiveCell.Value = myarray(n)
ActiveCell.Offset(1, 0).Select
Next

End Su

--
Message posted from http://www.ExcelForum.com

 
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
passing values to other sheets [email protected] New Users to Excel 1 February 23rd 08 02:03 AM
Looping between sheets picking up values on the way bungie Excel Worksheet Functions 3 March 5th 06 07:22 AM
Passing array of strings from DLL function to VBA Jag Man Excel Programming 0 January 12th 04 10:09 PM
PASSING an array to a sub in VBA Wombat[_2_] Excel Programming 2 November 30th 03 11:48 AM
Passing array to a function GB[_3_] Excel Programming 3 October 21st 03 09:59 AM


All times are GMT +1. The time now is 12:49 AM.

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

About Us

"It's about Microsoft Excel"