View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
John Coleman John Coleman is offline
external usenet poster
 
Posts: 274
Default Scrollbar with variable maximum and minimum

try

Private Sub ScrollBar1_Change()
ScrollBar1.Min = Range("A2").Value
ScrollBar1.Max = Range("A3").Value
End Sub


In your code:
1) You lack an end with to terminate the with block (but why use that
construct to set or invoke just 3 properties?)
2) You never use Rng - so why declare it?
3) If D1 is the linked cell (linked by setting the property manually
when you made thescroll bar) then the line setting its value is not
needed - though it wouldn't hurt
4) A stylistic point: Range("A1") or Cells(1,1) are more idiomatic
then Cells(1,"A")

I hope you enjoy learning Excel VBA - its a fun language.

HTH

-John Coleman

On Feb 7, 5:23 am, "Robert" wrote:
I would like to create a scrollbar which is linked tocells holding the
edge conditions (max & min). I did find some topics regarding this
subject, but none described exactly the problem I am experiencing.

I am new to writing VBcode but eager to learn. So far I came up with
the following code:

Private Sub ScrollBar1_Change()

Dim Top As Integer
Dim Dal As Integer

Top = Cells(3, "A").Value
Dal = Cells(2, "A").Value

With ScrollBar1
Dim Rng As Range
.Max = Top
.Min = Dal

Range("D1").Value = ScrollBar1.Value
End Sub

Is there anyone which is higher skilled in VBA as I am not (yet). What
am I missing.