Copy and Paste Macro

Whang56

New Member
Joined
Feb 2, 2012
Messages
42
I have 2 worksheets (WEEKLY SALES and GOALS). I need a macro to copy the sales from the WEEKLY SALES sheet and paste the values into the appropriate fields on the GOALS sheet- depending on the current week of the month we are in.
The cells to copy on the WEEKLY SALES tab are in E:8 and G:8.
The values need to be pasted to the Goals sheet in Column D and H. (relative to the E and G on the sales sheet) But the goals sheet is based monthly, not weekly. So on week 1, cells E:8 and G:8 in the WEEKLY SALES tab would be copied and paste values to the GOALS tab on D:14 and H:14, but on week 2, they would go to D:15 and H:15 - Week 3 - D:16 and H:16, etc. - up to week 5.
So I need the macro to read the cell (G:3) on the WEEKLY SALES tab that has the current week of the month and copy to the appropriate WEEK field on the GOALS tab. Then when the week of the month changes, the weeky sales figures can be deleted and the form WEEKLY SALES tab is reused every week.
I hope that I didn't confuse the issue too much. I have a copy of the workbook, but I'm pretty new to all this, so I'm not sure if I can post it.
Thanks in advance for any help on this.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
I have 2 worksheets (WEEKLY SALES and GOALS). So I need the macro to read the cell (G:3) on the WEEKLY SALES tab that has the current week of the month and copy to the appropriate WEEK field on the GOALS tab. Then when the week of the month changes, the weeky sales figures can be deleted and the form WEEKLY SALES tab is reused every week.
I hope that I didn't confuse the issue too much. I have a copy of the workbook, but I'm pretty new to all this, so I'm not sure if I can post it.
Thanks in advance for any help on this.
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p></o:p>

This code should be copied to your public code module1. Open the VBA Editor, Alt + F11, and if the large pane is dark, click Insert on the VBA Editor menu bar, then click Module. You can assign a keyboard shortcut to run the macro in Excel 07 and later click Macros on the Developer Ribbon then click Options. In Earlier Excel versions, I believe the Macro oprions were accessed from the tools menu.

Code:
Sub cpyStuff()
Dim sh1 As Worksheet, sh2 As Worksheet
Set sh1 = Sheets("WEEKLY SALES")
Set sh2 = Sheets("GOALS")
Set WkNbr = sh1.Range("G3")
For i = 1 To 5
If i = sh1.Range("G3") Then
sh2.Range("D" & i + 13) = sh1.Range("E8")
sh2.Range("H" & i + 13) = sh1.Range("G8")
Range("E8", "G8").ClearContents
End If
Next
End Sub
Code:
 
Upvote 0

Forum statistics

Threads
1,215,438
Messages
6,124,873
Members
449,192
Latest member
MoonDancer

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