Pasting Values between sheets in VBA

M

Matt

Hello,

I am creating a sales tracker to calculate weekly, monthly and yearly
sales. There are 5 Week Tabs, one Month To Date tab, and then a Year
to date tab which has a calendar design which i want to only hold the
final monthly data.
The way i would like to import this is to import the values by clicking
on a command button which says publish and it will import the current
monthly totals into the YTD range, on the YTD tab.

The commands i keep trying do not work, i tryed a few variations:

(curMonth is a string which returns the range to be used for the YTD
tab)
(curMTD is the range which contains the data on the MTD tab)
---------------------------------------------------------------------------------------------
YTD.Range(curMonth).value = MTD.Range(curMTD).Value

I have also tryed without YTD. and MTD. before range, and with
Sheets("YTD") and ("MTD")


These keep bugging for me and do not export to the range in the YTD
sheet.

Any suggestions or help would be greatly appreciated.

Thx.
Matt Titus
Waldorf MD
 
B

Bernard Liengme

Range references and names must be enclosed in quotes
On Sheet1 I have a cell named mysource; on Sheet2 I have a cell named
mytarget
The line of code copied a value from one to the other
Range("mytarget").Value = Range("mysource").Value
Since the names are unique in the workbook, I do not need to use sheet name.

Please note, a workbook is composed of sheets (worksheets and (optionally)
chartsheets)
Tabs are the things one clicks to open a sheet
Using the correct name makes conversations and searches in Help more
fruitful.
Sorry if you think me pedantic.
best wishes
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top