Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 11th, 2007, 12:46 PM
Authorized User
 
Join Date: Nov 2006
Posts: 14
Thanks: 2
Thanked 0 Times in 0 Posts
Send a message via Yahoo to webXtreme
Default ActiveX Control to Recalculate Cells

Hey,

I need help with my excel spreadsheet. We have a timesheet that calcuates employee regular time and overtime.

However, I need to add an checkbox that when the employee clicks the checkbox it will recalculate the regular and overtime fields so that the total in the overtime cell will change to 0 and add whatever was in the overtime cell to the regular cell.

Example:

Regular hours = 8
Overtime hours = 1

OnClick()
Regular hours = 9
Overtime hours = 0

THANKS!!


webXtreme
__________________
webXtreme
 
Old April 12th, 2007, 03:55 PM
Friend of Wrox
 
Join Date: Feb 2007
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

A checkbox or a button? Does this span over a range? Is this checkbox to loop through each worker?

Assuming Name is in Column A, Regular Hours is in column B, and overtime hours is in column C:
************************************************** ****************************
Private Sub CheckBox1_Click()

'Checks for overtime and adds it to the normal hours column then zeros it out
  Dim iRowOn As Long
  iRowOn = 2 'The row of the first name, assuming 1 header row
  Do While Cells(iRowOn, 1).value <> ""
    Cells(iRowOn, 2).Value = Val(Cells(iRowOn, 2).Value) + Val(Cells(iRowOn, 3).Value)
    Cells(iRowOn, 3).Value = 0
    iRowOn = iRowOn + 1
  Loop

End Sub

************************************************** ****************************






Similar Threads
Thread Thread Starter Forum Replies Last Post
Formatting Excel Cells Within ActiveX script ninel SQL Server DTS 3 January 28th, 2008 04:17 PM
how to merge cells in MS Flex Grid control manishdev Beginning VB 6 0 June 6th, 2007 09:03 AM
PropertyList activex control coder_gig79 VB Components 3 October 6th, 2004 10:32 PM
User-Defined Functions - How to recalculate? kmoran Excel VBA 1 October 5th, 2004 02:45 AM
How do I use an ActiveX Control? ArtDecade VB.NET 2002/2003 Basics 5 September 18th, 2004 03:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.