Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default Copy paste without selecting sheet or range

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(xl Up).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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 510
Default Copy paste without selecting sheet or range

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


--
Arvi Laanemets
( My real mail address: arvi.laanemets<attarkon.ee )



"Richard" wrote in message
...
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(xl Up).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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Copy paste without selecting sheet or range

Maybe

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



Mike

"Richard" wrote:

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(xl Up).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


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
MACRO: Selecting "Cancel" from a drop down to copy and paste entirerow to another sheet Nicole Hannington Excel Discussion (Misc queries) 1 July 20th 09 07:11 PM
MACRO: Selecting "Cancel" from a drop down to copy and paste entirerow to another sheet Nicole Hannington Excel Worksheet Functions 1 July 20th 09 06:51 PM
Macro - copy a range and paste it in a new sheet 12 times Eva Excel Worksheet Functions 0 September 26th 07 07:20 PM
Auto copy/ paste on relevant work sheet when selecting list item Niraj Manglam Excel Programming 1 June 6th 06 03:13 PM
Macro to copy range of cells and paste into 1 sheet Dean[_9_] Excel Programming 2 February 20th 06 12:53 AM


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