PC Review


Reply
Thread Tools Rate Thread

Command Button Changes Data Each Time It Is Pressed - Want it to workonce per worksheet.

 
 
f252863@hotmail.com
Guest
Posts: n/a
 
      23rd Apr 2008
I want to prevent a user from accidentally changing the data more than
once but keep in mind the worksheet is copied every day on to a new
tab with the current date on it (so it must be prevented only on that
worksheet).

Here is the current code:

Private Sub CommandButton58_Click()
Range("P203:S232").Select
Selection.Copy
Range("P202:S231").Select
ActiveSheet.PasteSpecial Format:=3, Link:=1, DisplayAsIcon:=False,
_
IconFileName:=False
ActiveSheet.Select
ActiveWorkbook.SendMail Recipients:=Range("i12", "i13"),
Subject:=Range("i11")
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub

I was thinking of adding code that would check a cell value, if blank
then change to "Done" and copy the range, if not blank (i.e., if user
clicks again) then skip copying of cell range. How do I write this
and is this a good way to do it?

Thanks!
 
Reply With Quote
 
 
 
 
Ian
Guest
Posts: n/a
 
      23rd Apr 2008
Your suggested method would work if you do something like

Private Sub CommandButton58_Click()
If Range("A1").Value <> "Done" then
---- your code here-----
Range("A1").Value = "Done"
Else
MsgBox("Can't do that on this sheet")
End If
End Sub

An alternative might be to compare the sheet name to the current date and
enable/disable the button accordingly. The exact method for this would
depend on the format of the date on the sheet name

Ian

<(E-Mail Removed)> wrote in message
news:b615f63b-9d1a-4a39-9aff-(E-Mail Removed)...
>I want to prevent a user from accidentally changing the data more than
> once but keep in mind the worksheet is copied every day on to a new
> tab with the current date on it (so it must be prevented only on that
> worksheet).
>
> Here is the current code:
>
> Private Sub CommandButton58_Click()
> Range("P203:S232").Select
> Selection.Copy
> Range("P202:S231").Select
> ActiveSheet.PasteSpecial Format:=3, Link:=1, DisplayAsIcon:=False,
> _
> IconFileName:=False
> ActiveSheet.Select
> ActiveWorkbook.SendMail Recipients:=Range("i12", "i13"),
> Subject:=Range("i11")
> ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
> End Sub
>
> I was thinking of adding code that would check a cell value, if blank
> then change to "Done" and copy the range, if not blank (i.e., if user
> clicks again) then skip copying of cell range. How do I write this
> and is this a good way to do it?
>
> Thanks!



 
Reply With Quote
 
f252863@hotmail.com
Guest
Posts: n/a
 
      23rd Apr 2008
Thanks Ian,

I had to modify it a little as making A1="Done" means that it will
carry over when the sheet is copied. As I have a macro to copy the
sheet it will now delete the A1 cell on the new sheet.

Cheers
 
Reply With Quote
 
Ian
Guest
Posts: n/a
 
      23rd Apr 2008
Hadn't thought that far ahead, but glad it worked.

Ian

<(E-Mail Removed)> wrote in message
news:ae7d6759-af97-420d-a11a-(E-Mail Removed)...
> Thanks Ian,
>
> I had to modify it a little as making A1="Done" means that it will
> carry over when the sheet is copied. As I have a macro to copy the
> sheet it will now delete the A1 cell on the new sheet.
>
> Cheers



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When adding command buttons, I pressed the wrong button...help! KCE Microsoft Access Forms 1 15th Aug 2008 04:48 AM
Command button on worksheet =?Utf-8?B?RGFsZSBGeWU=?= Microsoft Excel Programming 4 22nd Aug 2007 03:00 PM
Enter button jumps to next cell each time its pressed!!!! =?Utf-8?B?ZXZhc21hZ2Fjeg==?= Microsoft Excel Misc 3 17th Jun 2007 08:37 PM
command button wizard doesn't start even w/ wand pressed in =?Utf-8?B?YmFicw==?= Microsoft Access Forms 3 23rd Feb 2007 02:59 AM
Store data JUST entered in Activecell after clicking command button on worksheet Google@runit.nl Microsoft Excel Programming 1 23rd Aug 2006 04:20 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:45 PM.