+ Reply to Thread
Results 1 to 6 of 6

Code works when cell is manually changed only the first time and not with vba

  1. #1
    Registered User
    Join Date
    08-12-2014
    Location
    CA
    MS-Off Ver
    2011
    Posts
    72

    Code works when cell is manually changed only the first time and not with vba

    Hello,

    Two part question, firstly I have a form control spin button that inc/dec the cell T65 target cell by 1. When that cell is changed I need some vba code to be executed. However, it doesn't execute. Secondly, when I manually change the value, it works the first time and not after that.

    Second problem, I'd like the contents of K63 to show up pasted in a white box, but when the cell value changes I want the new contents of K63 to show in the white box but not a second, third and so on new box each time. I just need to be able to view the contents of the cell and edit the spreadsheet at the same time. Uploading a workbook is going to be very difficult for me because of how complicated this project is...

    Please Login or Register  to view this content.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    12,295

    Re: Code works when cell is manually changed only the first time and not with vba

    Have you enabled events after the first target? I only see it after the second target.

    Maybe supply a sample workbook if you want somebody to look at this closer.

  3. #3
    Registered User
    Join Date
    08-12-2014
    Location
    CA
    MS-Off Ver
    2011
    Posts
    72

    Re: Code works when cell is manually changed only the first time and not with vba

    Quote Originally Posted by davesexcel View Post
    Have you enabled events after the first target? I only see it after the second target.

    Maybe supply a sample workbook if you want somebody to look at this closer.
    Ok, it was actually easier to upload than I though. So in cell A2 you type in 0F and then look at T67 which searches "Raw Data" for matches and then all of the cells in grey are suppose to be what is copied to the form. These cells are based on T64 which is based on the count of T65 which is controlled by a spin button (form control) So when the spin button is clicked t65 changes and the data is supposed to be copied but into the form but its not working. In addition to this I need a view the contents of K63 that I can also edit spreadsheet while viewing the design. But if I click through 10 records I don't want 10 white boxes, just each time the contents are replaced...

    Design Master 1-1-100.xlsb

  4. #4
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    12,295

    Re: Code works when cell is manually changed only the first time and not with vba

    I'm not sure what you are doing, but worksheet_change does not work when a formula changes, just when the cell changes. Possible look onto Worksheet_Calculate

  5. #5
    Registered User
    Join Date
    08-12-2014
    Location
    CA
    MS-Off Ver
    2011
    Posts
    72

    Re: Code works when cell is manually changed only the first time and not with vba

    Okay maybe this is the problem. I will look into it

  6. #6
    Registered User
    Join Date
    08-12-2014
    Location
    CA
    MS-Off Ver
    2011
    Posts
    72

    Re: Code works when cell is manually changed only the first time and not with vba

    Quote Originally Posted by davesexcel View Post
    I'm not sure what you are doing, but worksheet_change does not work when a formula changes, just when the cell changes. Possible look onto Worksheet_Calculate
    It almost works, it does what it is suppose to but executes every time a cell is changed instead of the target. I am not familiar with this function.

    Private Sub Worksheet_Calculate()
    MsgBox "Recalculating"
    If IsNumeric(Range("$T$65")) Then
    Application.ScreenUpdating = False
    Application.CutCopyMode = False
    Application.EnableEvents = False

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Set 2 cells equal, while allowing either one to be manually changed
    By thanhmasterip in forum Excel General
    Replies: 4
    Last Post: 08-20-2014, 01:20 AM
  2. Alter Worksheet Change Event at specific time after the data is manually changed..
    By e4excel in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-22-2014, 05:12 PM
  3. My macro only works manually
    By jimemonge in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-03-2013, 09:13 AM
  4. Replies: 9
    Last Post: 08-30-2013, 07:49 AM
  5. Replies: 2
    Last Post: 05-04-2010, 06:19 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1