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 / May 2008

Tip: Looking for answers? Try searching our database.

Copy paste without selecting sheet or range

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Richard - 23 May 2008 11:27 GMT
Hi,

I have written a very short piece of code which only works when the correct
sheet is selected:

FinalRow = Worksheets("WeeklySummary").Range("B65536").End(xlUp).Row

Worksheets("WeeklySummary").Range("B" & FinalRow & ":z" & FinalRow -
52).Copy Destination:=Range("B" & FinalRow + 1)

However I would like this to work when I run the macro from a different
sheet ie sheet "WeeklySummary" isn't active.

I'm sure that I have to use the Dim Rng as Range syntax, but cannot quite
get it right.

Could someone please help

Many Thanks
Arvi Laanemets - 23 May 2008 12:16 GMT
Hi

FinalRow = Sheets("WeeklySummary").UsedRange.Rows.Count

Sheets("WeeklySummary").Range("B & FinalRow & ":Z" & FinalRow).Copy
Sheets("WeeklySummary").Range("B & (FinalRow+1) & ":Z" &
(FinalRow+1)).PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone,
SkipBlanks:=False, Transpose:=False

Signature

Arvi Laanemets
( My real mail address: arvi.laanemets<at>tarkon.ee )

> Hi,
>
[quoted text clipped - 16 lines]
>
> Many Thanks
Mike H - 23 May 2008 12:22 GMT
Maybe

Sub sonic()
FinalRow = Worksheets("WeeklySummary").Range("B65536").End(xlUp).Row
Worksheets("WeeklySummary").Range("B" & FinalRow & ":z" & FinalRow - 52).Copy
Worksheets("WeeklySummary").Range("B" & FinalRow + 1).PasteSpecial
End Sub

Mike

> Hi,
>
[quoted text clipped - 15 lines]
>
> Many Thanks
 
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.