View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Thomlinson Jim Thomlinson is offline
external usenet poster
 
Posts: 5,939
Default Code to run Value of cell rather than the Formula

That should work fine so long as the result of the formula in b5 is an
integer value. Give this a try...

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("B5")) Is Nothing Then Exit Sub
On Error GoTo endit
Application.EnableEvents = False
Rows("12:61").Hidden = True
Rows(12 & ":" & clng(Target.Value) + 11).Hidden = False
endit:
Application.EnableEvents = True
End Sub


--
HTH...

Jim Thomlinson


"Magnet Peddler" wrote:

I am currently running this code in my worksheet:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("B5")) Is Nothing Then Exit Sub
On Error GoTo endit
Application.EnableEvents = False
Rows("12:61").Hidden = True
Rows(12 & ":" & Target.Value + 11).Hidden = False
endit:
Application.EnableEvents = True
End Sub

If i simply enter a number in B5, the code works wonderfully. The problem is
that the value entered in B5 is not simply a number, but a formula which
pulls data from another worksheet. How can i make this work with the value
of b5 rather than the formula in B5?

I am a n00b to this, and would appreciate any help in the right direction.

Thanks in advance.

--
Murphy's first law of combat: Incoming fire always has the right of way.