Macro to copy data from one worksheet to another after existing data

mihir008

New Member
Joined
Jul 18, 2011
Messages
2
Hello!

I am a complete newbie to macros, so would greatly appreciate help with the following task..
I have to copy data from one worksheet (which regenerates data every week) to another worksheet, with the following conditions


1. Source sheet has columns A-W. Target sheet should have this same data from A-W
2. Column X in the target should have today's date (for all values copied - for my pivot table)
3. New data from the next week should be copied below the existing data, with column X accordingly updated.

As I said, I am very new to excel macros and would appreciate any help with the code.

Thanks in advance,

Mihir
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hello!

I am a complete newbie to macros, so would greatly appreciate help with the following task..
I have to copy data from one worksheet (which regenerates data every week) to another worksheet, with the following conditions


1. Source sheet has columns A-W. Target sheet should have this same data from A-W
2. Column X in the target should have today's date (for all values copied - for my pivot table)
3. New data from the next week should be copied below the existing data, with column X accordingly updated.

As I said, I am very new to excel macros and would appreciate any help with the code.

Thanks in advance,

Mihir

Does this help? Test first.

Code:
Sub mihir008()
Dim lr As Long
Dim lr2 As Long

lr = Sheets("Source").Cells(Rows.Count, 1).End(xlUp).Row

Sheets("Source").Range("A2:W" & lr).Copy Sheets("Target").Range("A" & Rows.Count).End(xlUp)(2)
Sheets("Target").Range(Range("X2"), Range("X" & Rows.Count)).End(xlUp).Value = Date



End Sub
 
Last edited:
Upvote 0
Hello!

I have a similar problem. Using this code as an example does anyone know how to alter it so that the values of a cell, rather than its formula will be copied?

Any help will be much appreciated!
 
Upvote 0
Hello!

I have a similar problem. Using this code as an example does anyone know how to alter it so that the values of a cell, rather than its formula will be copied?

Any help will be much appreciated!


I'm sure someone can help you. You need too provide a sample of your data and what you want to achieve.l
 
Upvote 0

Forum statistics

Threads
1,224,505
Messages
6,179,147
Members
452,891
Latest member
JUSTOUTOFMYREACH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top