Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Code to clear sheet

Hi all,
I have a button on my worksheet that activates a userform for data entry. I
want to include on this button an event that will clear contents of cells
B7:B22 and G7:G22. Also on the same event I want a cell value (AK3) to
increment by +1. The number in AK3 is limited to 3 digits so when it gets to
999 it must go to 000 on the next activation.
Can somebody please help me with a code for achieving this.

Kind Regards
gregork











;


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Code to clear sheet

Hi Gregor,

Worksheets("Sheet1").Range("B7:B22,G7:G22").Clear

Worksheets("Sheet1").Range("AK3").
If Value = 999 Then
.Value = 0
Else
.Value = .Value + 1
End If

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"gregork" wrote in message
...
Hi all,
I have a button on my worksheet that activates a userform for data entry.

I
want to include on this button an event that will clear contents of cells
B7:B22 and G7:G22. Also on the same event I want a cell value (AK3) to
increment by +1. The number in AK3 is limited to 3 digits so when it gets

to
999 it must go to 000 on the next activation.
Can somebody please help me with a code for achieving this.

Kind Regards
gregork











;




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default Code to clear sheet


I think Bob meant

With Worksheets("Sheet1").Range("AK3")
.Parent.Range("B7:B22,G7:G22").Clear
If .Value = 999 Then
.Value = 0
Else
.Value = .Value + 1
End If
End With


Regards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Code to clear sheet

Just another way:

With Worksheets("Sheet1")
.Range("B7:B22,G7:G33").Clear
With .Range("A7")
.Value = (.Value + 1) Mod 1000
End With
End With


In article ,
"gregork" wrote:

Hi all,
I have a button on my worksheet that activates a userform for data entry. I
want to include on this button an event that will clear contents of cells
B7:B22 and G7:G22. Also on the same event I want a cell value (AK3) to
increment by +1. The number in AK3 is limited to 3 digits so when it gets to
999 it must go to 000 on the next activation.
Can somebody please help me with a code for achieving this.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 102
Default Code to clear sheet

Hi all,
Many thanks for the replies.Small problem : I'm not certain where I should
be putting this code. I have tried putting it in with the userform
initialise code but it's not working there.

Kind Regards
Gregork


"JE McGimpsey" wrote in message
...
Just another way:

With Worksheets("Sheet1")
.Range("B7:B22,G7:G33").Clear
With .Range("A7")
.Value = (.Value + 1) Mod 1000
End With
End With


In article ,
"gregork" wrote:

Hi all,
I have a button on my worksheet that activates a userform for data

entry. I
want to include on this button an event that will clear contents of

cells
B7:B22 and G7:G22. Also on the same event I want a cell value (AK3) to
increment by +1. The number in AK3 is limited to 3 digits so when it

gets to
999 it must go to 000 on the next activation.
Can somebody please help me with a code for achieving this.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Code to clear sheet

Private Sub Commandbutton1_click()


With Worksheets("Sheet1")
.Range("B7:B22,G7:G33").Clear
With .Range("A7")
.Value = (.Value + 1) Mod 1000
End With
End With
Userform1.Show
End Sub

although no reason it should not work in the initialize event.

--
Regards,
Tom Ogilvy

gregork wrote in message
...
Hi all,
Many thanks for the replies.Small problem : I'm not certain where I should
be putting this code. I have tried putting it in with the userform
initialise code but it's not working there.

Kind Regards
Gregork


"JE McGimpsey" wrote in message
...
Just another way:

With Worksheets("Sheet1")
.Range("B7:B22,G7:G33").Clear
With .Range("A7")
.Value = (.Value + 1) Mod 1000
End With
End With


In article ,
"gregork" wrote:

Hi all,
I have a button on my worksheet that activates a userform for data

entry. I
want to include on this button an event that will clear contents of

cells
B7:B22 and G7:G22. Also on the same event I want a cell value (AK3)

to
increment by +1. The number in AK3 is limited to 3 digits so when it

gets to
999 it must go to 000 on the next activation.
Can somebody please help me with a code for achieving this.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Sheet to new Sheet and clear cells on original sheets Boiler-Todd Excel Discussion (Misc queries) 7 September 23rd 09 10:02 PM
Clear a set of combo boxes after a Submit of data to a new sheet. Jonah Excel Worksheet Functions 0 March 3rd 08 12:05 AM
Code to clear contents jk Excel Worksheet Functions 3 September 4th 06 06:25 PM
Macro help - copy row, clear, and paste on different sheet miker1999[_3_] Excel Programming 3 February 1st 04 03:22 AM
Clear row contents code Rohit Thomas Excel Programming 0 July 25th 03 10:38 PM


All times are GMT +1. The time now is 03:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"