#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 76
Default Array

Hello,

I had some VBA code that i have tried to condense into an Array but
with no success, can anyone help?


BEFORE....

Sheets("Summary").Select

Sheets("Tab1").Rows("2:100").Copy
lastrow = Sheets("Summary").Range("A65000").End(xlUp).Row
Sheets("Summary").Range("A" & lastrow + 1).PasteSpecial
Application.CutCopyMode = False

Sheets("Tab2").Rows("2:100").Copy
lastrow = Sheets("Summary").Range("A65000").End(xlUp).Row
Sheets("Summary").Range("A" & lastrow + 1).PasteSpecial
Application.CutCopyMode = False

Sheets("Summary").Select

AFTER...

Sheets("Summary").Select
For Each Sheet In Array("Tab1", "Tab2")
Rows("2:100").Copy
lastrow = Sheets("Summary").Range("A65000").End(xlUp).Row
Sheets("Summary").Range("A" & lastrow + 1).PasteSpecial
Application.CutCopyMode = False
Next Sheet
Sheets("Summary").Select

It just doesnt work? Can anyone spot my error(s) ??

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Array

Hi,

Try this

Sub after()
Dim sh As Worksheet
For Each sh In Worksheets(Array("Tab1", "Tab2"))
sh.Rows("2:100").Copy
lastrow = Sheets("Summary").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("Summary").Range("A" & lastrow + 1).PasteSpecial
Application.CutCopyMode = False
Next sh
End Sub

Mike

"NPell" wrote:

Hello,

I had some VBA code that i have tried to condense into an Array but
with no success, can anyone help?


BEFORE....

Sheets("Summary").Select

Sheets("Tab1").Rows("2:100").Copy
lastrow = Sheets("Summary").Range("A65000").End(xlUp).Row
Sheets("Summary").Range("A" & lastrow + 1).PasteSpecial
Application.CutCopyMode = False

Sheets("Tab2").Rows("2:100").Copy
lastrow = Sheets("Summary").Range("A65000").End(xlUp).Row
Sheets("Summary").Range("A" & lastrow + 1).PasteSpecial
Application.CutCopyMode = False

Sheets("Summary").Select

AFTER...

Sheets("Summary").Select
For Each Sheet In Array("Tab1", "Tab2")
Rows("2:100").Copy
lastrow = Sheets("Summary").Range("A65000").End(xlUp).Row
Sheets("Summary").Range("A" & lastrow + 1).PasteSpecial
Application.CutCopyMode = False
Next Sheet
Sheets("Summary").Select

It just doesnt work? Can anyone spot my error(s) ??

Thanks

Reply
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
Prevent cell/array references from changing when altering/moving thecell/array nme Excel Discussion (Misc queries) 1 September 19th 08 01:53 PM
Populate an array that is a subset of a larger array? Jeff Excel Worksheet Functions 1 September 25th 07 12:51 AM
Array: Counting multiple values within array Trilux_nogo Excel Worksheet Functions 4 April 16th 07 03:12 AM
meaning of : IF(Switch; Average(array A, array B); array A) DXAT Excel Worksheet Functions 1 October 24th 06 06:11 PM
combining cells and array from different sheets into an array to pass to IRR() [email protected] Excel Discussion (Misc queries) 3 September 11th 06 07:17 AM


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

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"