Userform fields not updating when spinbutton activated

rizzo93

Active Member
Joined
Jan 22, 2015
Messages
299
Office Version
  1. 365
All fields on my userform reference cells on a worksheet. When the form displays for the first time, the fields show the appropriate values for those cells.

But when the user clicks the spinbutton up or down on the form, the contents of the cells change, but NOT the fields themselves.

The only thing that does update is a ListBox that references a range on the same worksheet as the other fields.

What am I missing, please?


Code:
Private Sub SpinButton1_SpinUp()

    Worksheets("GhostData").Range("CK6").Value = Worksheets("GhostData").Range("CK6").Value + 1

End Sub

Private Sub SpinButton1_SpinDown()
    Worksheets("GhostData").Range("CK6").Value = Worksheets("GhostData").Range("CK6").Value - 1
End Sub

Private Sub UserForm_Initialize()
    'Enters the project ID of the active cell on Periscope
    Worksheets("GhostData").Range("CK5") = Worksheets("Periscope").Cells(ActiveCell.Row, 76).Value
    'Enters the row number of where the project ID is located on PivotData
    Worksheets("GhostData").Range("CK6") = Worksheets("Periscope").Cells(ActiveCell.Row, 78).Value
    ProjectIDField.Text = Worksheets("GhostData").Range("CK10")
    ProjectNameField2.Text = Worksheets("GhostData").Range("CK11")
    PortfolioField.Text = Worksheets("GhostData").Range("CK12")
    
End Sub
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
When I look at your script I see nothing that tells the spin button to update the field.
The spin button tells the cell to update but not the field
I would think you need to add something like this

Field.value=cell.value

And I always think using active cell is dangerous
If the active cell is always the same why not specify the exact range.

I see nothing in the script that moves the active cell.
 
Last edited:
Upvote 0
Thanks for the assist, My Answer Is This.

I did have some code for the spin button, but failed to post it. Here it is:


Code:
Private Sub SpinButton1_Up()

    Worksheets("Periscope").Cells(ActiveCell.Row, 76).Value = Worksheets("Periscope").Cells(ActiveCell.Row, 76).Value + 1
    
End Sub


Granted it's only to increase the spin count, but I was just trying to keep it simple before I implemented the decreasing portion.


I understand what you are saying with the example you provided, but I thought this code would be its equivalent, yes?


Code:
ProjectNameField2.Text = Worksheets("GhostData").Range("CK11")

I sense that I'm missing something within the code I originally posted that causes the fields to actually update with the new content.

Would you agree? And if so, what would that code be please?
 
Upvote 0
You said:
ProjectNameField2.Text

If this is the name of your textbox why not try it and see.
 
Upvote 0
Upon opening the form, the fields show the appropriate content. And the cell contents do change when the spinbutton is clicked. But as I explained previously, the fields do not update. This is the problem I am trying to solve.
 
Upvote 0
You need to explain what are the names of the fields you want updated.
And in Userforms we normally refer to these as Texbox's not fields.

So show me the entire script your using which you want updating the Textbox's on the userform.
 
Upvote 0
The only code you've posted that populates values on the userform is this code in the Initialize event.
Code:
    ProjectIDField.Text = Worksheets("GhostData").Range("CK10")
    ProjectNameField2.Text = Worksheets("GhostData").Range("CK11")
    PortfolioField.Text = Worksheets("GhostData").Range("CK12")
If you want to change the values in the textboxes when the spinbutton value is changed then try repeating this code in the SpinUp/Down events of the spin button.
 
Upvote 0
Here is my code:

Code:
Private Sub SpinButton1_SpinUp()

    Worksheets("GhostData").Range("CK6").Value = Worksheets("GhostData").Range("CK6").Value + 1

End Sub

Private Sub SpinButton1_SpinDown()
    Worksheets("GhostData").Range("CK6").Value = Worksheets("GhostData").Range("CK6").Value - 1
End Sub

Private Sub UserForm_Initialize()
    'Enters the project ID of the active cell on Periscope
    Worksheets("GhostData").Range("CK5") = Worksheets("Periscope").Cells(ActiveCell.Row, 76).Value
    'Enters the row number of where the project ID is located on PivotData
    Worksheets("GhostData").Range("CK6") = Worksheets("Periscope").Cells(ActiveCell.Row, 78).Value
    ProjectIDField.Text = Worksheets("GhostData").Range("CK10")
    ProjectNameField2.Text = Worksheets("GhostData").Range("CK11")
    PortfolioField.Text = Worksheets("GhostData").Range("CK12")
    
End Sub

Thank again.
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,022
Members
448,939
Latest member
Leon Leenders

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top