View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Gleam Gleam is offline
external usenet poster
 
Posts: 87
Default Public variable not storing

I set the number of rows on opening a file but when I detect a change in a
sheet, the number of rows is empty. Help please!

The code for ThisWorkbook:
Public NrowsSt As Integer
Private Sub Workbook_Open()
NrowsSt = Range("MyRange").Rows.Count
MsgBox NrowsSt
End Sub


The code for Sheet1:

Private Sub Worksheet_Change(ByVal Target As Range)
MsgBox NrowsSt
Nrows = Range("MyRange").Rows.Count
If Nrows < NrowsSt Then
If Nrows NrowsSt Then
MsgBox "No of rows inserted =" & Nrows - NrowsSt
Else
MsgBox "No of rows deleted =" & NrowsSt - Nrows
End If
End If
End Sub