LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Copy and Paste Macro

I have recorded the following Macro
Windows("Copy of Headcount Review 2006.xls").Activate
ActiveWindow.SmallScroll Down:=-21
Range("A3:AF44").Select
Selection.Copy
Windows("Core Data Example.xls").Activate
Sheets("UK Downstream").Select
Range("A3").Select
Selection.Insert Shift:=xlDown
This is to import data which will be arriving Friday from 20+ business units
into a single core data sheet with tabs for each unit. The problem I have is
the Range("A3:AF44").Select line the reason being that although the columns
will be A:AF will stay constant the rows will vary. I have found the
following pieces of code to select a variable range
dim LastRow as long
with worksheets("sheet1")
lastrow = .cells(.rows.count,"A").end(xlup).row
.range("a1:x" & lastrow).copy _
destination:=....
end with
Or
Set rng = Range(Range("A1"), Cells(Rows.Count, "A").End(xlUp)).Resize(,
21)
rng.Name = "range_name"
Would anyone be able to tell me which is best and how i would insert it into
the code above??
 
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 multiple worksheets of a workbook, and paste onto a Word document ( either create new doc file or paste onto an existing file.) I need this done by VBA, Excel Macro Steven Excel Programming 1 October 17th 05 08:56 AM
Copy and Paste macro needs to paste to a changing cell reference loulou Excel Programming 0 February 24th 05 10:29 AM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
Macro to Copy/Paste then Paste to Next Line tomkarakowski Excel Programming 1 May 28th 04 01:19 AM
copy/paste macro PLN Excel Programming 2 July 21st 03 10:15 PM


All times are GMT +1. The time now is 04:14 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"