Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Diane Collins   on Nov 09 In MS Office Category.

  
Question Answered By: Binge Fischer   on Nov 09

I ended up with a sub driven by a command button and the function  as follows

We can't use the worksheet.change event because it is fired every time the sub
changes one of the fields so it gets in a loop.

The function is in a module and the sub is in the worksheet code (although for
practical purposes I will be moving it to a module).

Private Sub RecalcSeq()
Dim i As Integer
Dim Number_Of_Rows As Integer
Dim Seq_Number As Integer

' Determine number  of rows containing data
Number_Of_Rows = UsedRange.Rows.Count

Seq_Number = 1
For i = 1 To Number_Of_Rows
If Left(Range("D" & i).Formula, 5) = "=seq(" Then
Range("D" & i).Formula = "=seq(" & Seq_Number & ")"
Seq_Number = Seq_Number + 1
End If
Next i

End Sub

Function seq(intSeqNo As Integer) As Integer
seq = intSeqNo
End Function

Share: 

 

This Question has 9 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Sequence field Or get search suggestion and latest updates.


Tagged: