Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Copy/Paste to all Worksheets

I need a macro to copy every 3rd cell in a worksheet and paste it into
all corresponding worksheets in another workbook. For Example I have a
worksheet will all companies and their rating. And another workbook
with each company as a sheet. I need to copy their rating and paste it
into their company sheet.
Any Help would be appreciated.


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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 216
Default Copy/Paste to all Worksheets

Try something like this:
'Dimension variables
Dim wbSource As Workbook
Dim wbTarget As Workbook
Dim wsSource As Worksheet
Dim wsTarget As Worksheet

'Get the book and sheet where the information is to be
copied from
Set wbSource = Excel.Workbooks.Open("C:\source.xls")
Set wsSource = wbSource.Sheets("Sheet1")

'Get the book where the information is to be copied to
Set wbTarget = Excel.Workbooks.Open("C:\target.xls")

'Loop through all of the sheets in the target book and
set the value equal to the value from the source book
For Each wsTarget In wbTarget.Sheets
'Set Row 3, Column 1 value in the target sheet equal
to Row 3, Column 1 in the source sheet
wsTarget.Cells(3, 1).Value = wsSource.Cells(3,
1).Value
'then you could repeat this for every 3rd cell by
manually typing in each 3rd cell:
wsTarget.Cells(6, 1).Value = wsSource.Cells(6,
1).Value
wsTarget.Cells(9, 1).Value = wsSource.Cells(9,
1).Value

'or come up with some routine to loop through the
cells, something like...
Dim i As Long
i = 3
While i < 21
wsTarget.Cells(i, 1).Value = wsSource.Cells(i,
1).Value
i = i + 3
Wend
Next

'Clean up variables
Set wsTarget = Nothing
Set wbTarget = Nothing
Set wsSource = Nothing
Set wbSource = Nothing


-----Original Message-----
I need a macro to copy every 3rd cell in a worksheet and

paste it into
all corresponding worksheets in another workbook. For

Example I have a
worksheet will all companies and their rating. And

another workbook
with each company as a sheet. I need to copy their

rating and paste it
into their company sheet.
Any Help would be appreciated.


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

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copy/Paste to all Worksheets

for i = 1 to 200 step 3
set rng = cells(i,1)
rng.EntireRow.copy Destination:=workbooks("Book2.xls") _
.worksheets(rng.Value).Cells(rows.count,1).End(xlu p)(2)
Next

--
Regards,
Tom Ogilvy

"sharon " wrote in message
...
I need a macro to copy every 3rd cell in a worksheet and paste it into
all corresponding worksheets in another workbook. For Example I have a
worksheet will all companies and their rating. And another workbook
with each company as a sheet. I need to copy their rating and paste it
into their company sheet.
Any Help would be appreciated.


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



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
Copy/paste from many worksheets in the same spreadsheet into one r jaymesglew Excel Worksheet Functions 2 September 2nd 08 03:17 PM
Copy and paste a name list across worksheets chungacs Excel Discussion (Misc queries) 2 June 14th 08 07:39 AM
Copy and Paste between 2 worksheets with VBA Dave Y Excel Worksheet Functions 2 June 15th 05 03:47 PM
cannot copy and paste worksheets or workbooks Tim Excel Discussion (Misc queries) 1 March 29th 05 07:17 PM
copy/paste data between worksheets Anthony Excel Discussion (Misc queries) 0 February 5th 05 12:31 AM


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