Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 1
Default Paste into grouped sheets using VB

I am trying to paste data from one sheet into an array of grouped sheets, but using "Selection" or other like words isn't working. Please help! I am new to this board, so please pardon any formatting issues. Here's what I have:

Sub copy()
'
' copy Macro
' Macro recorded 1/16/2009 by n893581x
'

'
Sheets("Last").Select
Range("BP1:DO4").Select
Selection.copy
Dim MyArray() As String 'Dimension an array as string type
Dim iLoop As Integer 'Dimension a variable as integer to be used for a loop
Dim Cnt As Integer 'Dimension a variable as integer for a counter for each sheet named group
' Start a loop through all sheets in the workbook
For iLoop = 1 To Sheets.Count
' Check if the sheets has the name "Group" and then a number
If Worksheets(iLoop).Name Like "#*" Then
' Sheet Match Found So Count
Cnt = Cnt + 1
' Redimension the array and preserve any existing entrys
ReDim Preserve MyArray(Cnt)
' Add the sheet to the array
MyArray(Cnt) = Worksheets(iLoop).Name
End If
Next iLoop
' Check if the array contains any sheets and if so select them
If UBound(MyArray) 0 Then Worksheets(MyArray).Select
Sheets("48643").Select
Range("BP1").Select
.PasteSpecial Paste:=xlPasteValues
Range("B32").Select


End Sub

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com/default.aspx?ref=ng
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,124
Default Paste into grouped sheets using VB

A bit simpler withOUT any selections run from anywhere in the workbook.

Sub copyvaluestoshts()
Dim i As Long
Sheets("last").Range("BP1:DO4").Copy
For i = 1 To Sheets.Count
If UCase(Left(Sheets(i).Name, 5)) = "GROUP" Then
Sheets(i).Range("bp1").PasteSpecial Paste:=xlPasteValues
End If
Next
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"kara stevenson" wrote in message ...
I am trying to paste data from one sheet into an array of grouped sheets,
but using "Selection" or other like words isn't working. Please help! I
am new to this board, so please pardon any formatting issues. Here's what
I have:

Sub copy()
'
' copy Macro
' Macro recorded 1/16/2009 by n893581x
'

'
Sheets("Last").Select
Range("BP1:DO4").Select
Selection.copy
Dim MyArray() As String 'Dimension an array as string type
Dim iLoop As Integer 'Dimension a variable as integer to be used for a
loop
Dim Cnt As Integer 'Dimension a variable as integer for a counter for
each sheet named group
' Start a loop through all sheets in the workbook
For iLoop = 1 To Sheets.Count
' Check if the sheets has the name "Group" and then a number
If Worksheets(iLoop).Name Like "#*" Then
' Sheet Match Found So Count
Cnt = Cnt + 1
' Redimension the array and preserve any existing entrys
ReDim Preserve MyArray(Cnt)
' Add the sheet to the array
MyArray(Cnt) = Worksheets(iLoop).Name
End If
Next iLoop
' Check if the array contains any sheets and if so select them
If UBound(MyArray) 0 Then Worksheets(MyArray).Select
Sheets("48643").Select
Range("BP1").Select
.PasteSpecial Paste:=xlPasteValues
Range("B32").Select


End Sub

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com/default.aspx?ref=ng

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 35,218
Default Paste into grouped sheets using VB

I'd just loop through the sheets and paste when I found a match in names:

Option Explicit
Sub myCopy()

Dim RngToCopy As Range
Dim wks As Worksheet

Set RngToCopy = Worksheets("Last").Range("bp1:do4")

For Each wks In ActiveWorkbook.Worksheets
If LCase(wks.Name) Like LCase("#*") Then
RngToCopy.copy
wks.Range("bp1").PasteSpecial Paste:=xlPasteValues
End If
Next wks

End Sub

kara, stevenson wrote:

I am trying to paste data from one sheet into an array of grouped sheets, but using "Selection" or other like words isn't working. Please help! I am new to this board, so please pardon any formatting issues. Here's what I have:

Sub copy()
'
' copy Macro
' Macro recorded 1/16/2009 by n893581x
'

'
Sheets("Last").Select
Range("BP1:DO4").Select
Selection.copy
Dim MyArray() As String 'Dimension an array as string type
Dim iLoop As Integer 'Dimension a variable as integer to be used for a loop
Dim Cnt As Integer 'Dimension a variable as integer for a counter for each sheet named group
' Start a loop through all sheets in the workbook
For iLoop = 1 To Sheets.Count
' Check if the sheets has the name "Group" and then a number
If Worksheets(iLoop).Name Like "#*" Then
' Sheet Match Found So Count
Cnt = Cnt + 1
' Redimension the array and preserve any existing entrys
ReDim Preserve MyArray(Cnt)
' Add the sheet to the array
MyArray(Cnt) = Worksheets(iLoop).Name
End If
Next iLoop
' Check if the array contains any sheets and if so select them
If UBound(MyArray) 0 Then Worksheets(MyArray).Select
Sheets("48643").Select
Range("BP1").Select
.PasteSpecial Paste:=xlPasteValues
Range("B32").Select


End Sub

EggHeadCafe - .NET Developer Portal of Choice
http://www.eggheadcafe.com/default.aspx?ref=ng


--

Dave Peterson
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
Export all grouped information to different sheets stumac Excel Discussion (Misc queries) 2 April 5th 07 02:10 PM
create alert when in sheets are grouped Twishlist Excel Worksheet Functions 1 April 5th 07 04:50 AM
Grouped Sheets - Windows Arrange JMay Excel Discussion (Misc queries) 8 November 15th 06 12:53 AM
Replace with Grouped Sheets Jim May Excel Discussion (Misc queries) 4 September 15th 06 02:19 PM
Grouped Sheets and Formating Pank Mehta Excel Discussion (Misc queries) 3 March 24th 05 01:42 AM


All times are GMT +1. The time now is 01:46 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"