Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Code to copy data

Hello All

Im wandering if anyone out there can help me.

I have a spreadsheet which contains master data (Persons Details) and on a
separate worksheet a template for a weekly Register.

The master data can vary from week to week as people come and go.

What I do is on a weekly basis is create a register based on the master data
for that week and email it to a colleague to complete.

What I want to be able to do is to automate the process so when I run the
macro it automatically counts the number of rows populated in the master,
selects the first three columns of data, then in the register template,
autimatically insert the number of rows required then paste the data in.

Im fairly new to VBA, and have had a go but just falling short.

Thanks in anticipation.

D

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200910/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code to copy data


Where is the register template and where in tthe template do you want to
Insert the data. It may help if you perform the function manually and
recorded a macro. I would recommend doing a copy of the source data and
using the INSERT Copied cells. First use copy for the source data and
then select the 1st location where you want to place the data. Next
right click mouse and select Insert Copied Cells.


You can post the recorded macro and I can make any required changes to
make it work properly for different number of rows.


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=145547

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Code to copy data

Thanks Joe

I Have a a Sheet Called Master Data and Sheet Named Register Template

Ive Recorded the Macro as you said, please see below

Thanks

D

Sub CopyDetails()
'
' CopyDetails Macro
' Macro recorded 19/10/2009 by dchu0506
'

'
Range("A2:D5").Select
Selection.Copy
Sheets("Register Template").Select
Selection.Insert Shift:=xlDown
Range("E7:T7").Select
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("E7:T10"), Type:=xlFillDefault
Range("E7:T10").Select
Range("A1").Select
End Sub

joel wrote:
Where is the register template and where in tthe template do you want t
Insert the data. It may help if you perform the function manually an
recorded a macro. I would recommend doing a copy of the source data an
using the INSERT Copied cells. First use copy for the source data an
then select the 1st location where you want to place the data. Nex
right click mouse and select Insert Copied Cells.

You can post the recorded macro and I can make any required changes t
make it work properly for different number of rows

--
joe


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200910/1

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code to copy data


I don't understand what yo are trying to do with the autofill. It looks
like it over-writing the data that was pasted. Are yo ujust trying to
open the same number of rows in the template as the orginal worksheet?


Sub CopyDetails()
'
' CopyDetails Macro
' Macro recorded 19/10/2009 by dchu0506
'

'
With ActiveSheet
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
.Range("A2:D" & LastRow).Copy

End With
With Sheets("Register Template")
.Range("E7").Insert Shift:=xlDown
LastRow = .Range("E" & Rows.Count).End(xlUp).Row
.Range("A1").Select
End With
End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=145547

  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Code to copy data

Hi Joel

Thanks Joel

Sorry, I missed the bit in the original post woth regard to the autofill.

I am only copying the first 4 columns of data in the master to the register.
On the first row in the register template I have some Data Validation which I
wanted to apply to all lines of the copied data.

I hope that makes sense and Thanks again for the help.

Cheers

D


joel wrote:
I don't understand what yo are trying to do with the autofill. It look
like it over-writing the data that was pasted. Are yo ujust trying t
open the same number of rows in the template as the orginal worksheet?

Sub CopyDetails()
'
' CopyDetails Macro
' Macro recorded 19/10/2009 by dchu0506
'

'
With ActiveSheet
LastRow = .Range("A" & Rows.Count).End(xlUp).Row
.Range("A2:D" & LastRow).Copy

End With
With Sheets("Register Template")
.Range("E7").Insert Shift:=xlDown
LastRow = .Range("E" & Rows.Count).End(xlUp).Row
.Range("A1").Select
End With
End Su

--
joe


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200910/1

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Code to copy data


The copy methois I used will keep the data validation in the cells.


--
joel
------------------------------------------------------------------------
joel's Profile: http://www.thecodecage.com/forumz/member.php?userid=229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=145547

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default Code to copy data

Thanks for your help Joe much appreciated.

And thanks for your response too Don, Ive managed to get it workin from what
Joe sent through

Cheers

D


dazoloko wrote:
Hi Joel

Thanks Joel

Sorry, I missed the bit in the original post woth regard to the autofill.

I am only copying the first 4 columns of data in the master to the register.
On the first row in the register template I have some Data Validation which I
wanted to apply to all lines of the copied data.

I hope that makes sense and Thanks again for the help.

Cheers

D

I don't understand what yo are trying to do with the autofill. It look
like it over-writing the data that was pasted. Are yo ujust trying t

[quoted text clipped - 21 lines]
--
joe


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200910/1

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
Code to copy and paste those cells that have data lostandcondfused Excel Programming 0 January 6th 09 09:53 PM
Copy all data into one sheet and insert origin data... code amend... [email protected][_2_] Excel Programming 3 September 15th 08 02:54 PM
Code to Copy Data from One Spreadsheet To Another Rob Excel Discussion (Misc queries) 9 June 9th 07 11:03 AM
Command Button Code to copy data sho Excel Programming 3 July 7th 04 01:53 PM
Code to copy data from 1 file to another The Gza Excel Programming 1 February 28th 04 06:29 AM


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