Not resetting all cells

C

Chuck

The following code works for the first ActiveSheet.ScrollBar1.Value command
works, but the ActiveSheet.ScrollBar2-9 commands do not. The last 4 commands
(ActiveSheet.Range("D10) through "D16" also work. Appreciate any help.
Thanks.

ActiveSheet.ScrollBar1.Value = ActiveSheet.Range("U31")
ActiveSheet.ScrollBar2.Value = ActiveSheet.Range("U32")
ActiveSheet.ScrollBar3.Value = ActiveSheet.Range("U33")
ActiveSheet.ScrollBar4.Value = ActiveSheet.Range("U34")
ActiveSheet.ScrollBar5.Value = ActiveSheet.Range("U35")
ActiveSheet.ScrollBar6.Value = ActiveSheet.Range("U36")
ActiveSheet.ScrollBar7.Value = ActiveSheet.Range("U37")
ActiveSheet.ScrollBar8.Value = ActiveSheet.Range("U38")
ActiveSheet.ScrollBar9.Value = ActiveSheet.Range("U39")

ActiveSheet.Range("D10") = Range("C10")
ActiveSheet.Range("D12") = Range("C12")
ActiveSheet.Range("D14") = Range("C14")
ActiveSheet.Range("D16") = Range("C16")
 
C

Chuck

Thanks for responding. However, the scrollbars and the linked cells are all
formatted the same (as numbers).
 
G

Gord Dibben

Formatting means nothing.

If the cells' values are actually text, re-formatting to General or Number will
not change that fact.

You must coerce them from text to numeric.


Gord Dibben MS Excel MVP
 
J

JLGWhiz

What are you expecting to happen with the command? That is, do you expect
the scrollbox for those eight scrollbars to be in a position between the max
and min that would result in a scroll by equating to the values in cells
U32-U39? When you say it is not working, it helps to define what you are
expecting it to do.
 
C

Chuck

What I would like to happen is that when the Command Button is clicked, the
scrollbar returns to the value in cell U31, for example. Let's say that cell
U31 has a value of 5,000 and the current value of the scrollbar is 4,500.
When the Command Button is clicked the scrollbar should move to 5,000. This
only happens with the first line of code (referring to cell U31), but not the
lines of code referring to U32-U39.
 
J

JLGWhiz

Then like Gord wrote, you need to make sure that the value you see in your
reference cells is, in fact, numerical. You can run an easy check with a
message box: MsgBox ActiveSheet.Range("U32")

If you see "5000" in the message box, you identify the problem as text.
If you see 5000 in the message box, and it still does not set to the correct
position, then you have another type problem elsewhere.

You can concatenate the ranges and check them all at once.

Good Luck
 
C

Chuck

OK. Thanks for all of your help.

JLGWhiz said:
Then like Gord wrote, you need to make sure that the value you see in your
reference cells is, in fact, numerical. You can run an easy check with a
message box: MsgBox ActiveSheet.Range("U32")

If you see "5000" in the message box, you identify the problem as text.
If you see 5000 in the message box, and it still does not set to the correct
position, then you have another type problem elsewhere.

You can concatenate the ranges and check them all at once.

Good Luck
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top