Saving VBA Code And A Counter

Morrissey

Board Regular
Joined
Mar 8, 2002
Messages
85
Hello I have A Problem And I Need A Solution Quickly, I Have A Button Which When Clicked I Want To Do The Follwoing Things

->Copy A Selection Of My Cells from 'A1' to 'G49' (I Have Also Named These cells a range called 'export1' Onto A New Workbook

->Have This New Workbook Automatically Saved While And Then Have To Workbook Closed

When This Has Been Done 250 Times I Would Like A Message Box To Come Up Saying A Customised Message

I Need All The VB Code For This Please Help Me!
 
arasH, oncE yoU havE thE codE anD havE handeD iT iN (iN lesS thaN 12 hourS timE), dO yoU wanT mE tO comE rounD anD chiN youR tutoR?
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
OK, I think I've got you now.


Here's a quick link to opening the Excel workbook for access to read and write.

http://www.mrexcel.com/board/viewtopic.php?topic=671&forum=2

Instead of doing msgbox "The value is" you'll want to stick some code in like:

<pre>
'Copy and paste the range:
Sheets("Sheet1").Range("A1:G48").Copy Destination:=wkbk.Sheets("Sheet1").Range("A1")</pre>

Obviously you'll change this code to refer to the actual workbooks and ranges you'll use.

To do the 250 times bit. You'll need to find a nice empty cell somewhere on your spreadsheet where the user wont easily find it.

When the button is clicked, stick this code at the front of your macro:

<pre>
Sheets("Sheet1").Range("IV65536").value = Sheets("Sheet1").Range("IV65536").value + 1

if Sheets("Sheet1").Range("IV65536").value = 250 then msgbox "hi I've been opened 250 time, by someone copying Arash the moronic A Level student's ideas for writing data to removable media."</pre>

that should work. Anyway, I need to fly now. If you've got any problems, I'll be back on Monday. Take it easy.
 
Upvote 0
On 2002-03-21 13:47, Morrissey wrote:
it doesn't matter but Nero

So you not controling the writing of CD from excel just wnat a reminder to manually copy you data



Why not just ask someone to do your project for you and then you won't have to mess with it at all? That's the route Arash would have taken.
This message was edited by Steve Hartman on 2002-03-21 14:07
 
Upvote 0

Forum statistics

Threads
1,214,591
Messages
6,120,424
Members
448,961
Latest member
nzskater

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