Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Copy paste ranges from multiple sheets

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Woody1313 - 30 Jan 2006 13:41 GMT
Hi

I am new to VBA and need help on the following problem:

I have  a workbook with 2 types of worksheets. 2 permanent worksheet in
the begining and 2 and the end of the work book. In between theses
worksheets are a variable amount of sheets which a user can create.

I need to copy and paste a specific range from the variable sheets into
a "Data" sheet (a permanent sheet) , one column for each sheet.

I  have read a few books and this is what I Have so far

Sub copydna()
Dim lastsheet As Long
Dim rng As Range
lastsheet = Sheets.Count
For N = 3 To lastsheet - 3
Sheets(N).Activate
Set rng = Range("H49:H303")
Sheets("Data").Cells(1, 1).offset(0, 1).Value = rng.Value
Next
End Sub

It is not correct , I am missing the  correct way to offset the range.

I will be greatful for any help.

Thanks

John
Tom Ogilvy - 30 Jan 2006 14:14 GMT
Sub copydna()
Dim lastsheet As Long
Dim rng As Range
lastsheet = Sheets.Count
For N = 3 To lastsheet - 3
Sheets(N).Activate
Set rng = Range("H49:H303")
Sheets("Data").Cells(1, 1).offset(0, N-3) _
   .Resize(255,1).Value = rng.Value
Next
End Sub

Signature

regards,
Tom Ogilvy

> Hi
>
[quoted text clipped - 27 lines]
>
> John
Woody1313 - 30 Jan 2006 15:37 GMT
Thanks

Works great!!
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.