Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Changing cells in a event handler under Excel

Changing cells in a event handler under Excel

Scheduled Pinned Locked Moved Visual Basic
sharepointdebugging
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    R Schmidt
    wrote on last edited by
    #1

    Hello, I programmed a click event handler for a button on a worksheet. In this handler I wanted to change some cells. But when the handler changed the first cell it aborted directly after the comand. Here's my code: This is the event handler itself, it is calling another function that is doing the work: Private Sub bReorgWorkTime_Click() ReorgWorkTime bReorgWorkTime.Parent End Sub Public Function ReorgWorkTime(xButtonWorksheet As Worksheet) Dim iDay As Integer Dim xWorkTime As Variant Dim xReorgedTime As Variant Dim dWorkTime As Double Dim bOldEventsEnabled As Boolean iDay = ROW_DAY_1 bOldEventsEnabled = Application.EnableEvents Application.EnableEvents = False ' Fill in all days without over times: While (iDay <= ROW_DAY_31) xWorkTime = xButtonWorksheet.Cells(iDay, COL_WORKED_TIME) If (IsNumeric(xWorkTime) And Not IsEmpty(xWorkTime)) Then dWorkTime = xWorkTime xButtonWorksheet.Cells(iDay, COL_REORGED_TIME) = dWorkTime ' Aborts here Else xButtonWorksheet.Cells(iDay, COL_REORGED_TIME) = "" ' or here End If iDay = iDay + 1 Wend Application.EnableEvents = bOldEventsEnabled End Function Believing the debugger the "iDay = iDay + 1" line isn't even reached! I use Excel 2002 SP-1 German

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups