P
PropKid
I won't post all of the code here because it's too extensive but here's
a watered down version (all variables declarations are not listed):
Dim i as integer
Dim PortName As String
Dim ReviewSht As String
Dim ModelSht As String
Dim HoldingsSht As String
Dim Model As Range
PortName = Right(ActiveSheet.Name, Len(ActiveSheet.Name) - 15)
ReviewSht = "Price Weight - " & PortName
ModelSht = "Model Data - " & PortName
HoldingsSht = "Holdings - " & PortName
Application.ScreenUpdating = False
With Worksheets(ModelSht).Range("A9")
Range(.Offset(0, 0), .End(xlDown).End(xlToRight)).Name =
"ModelRange"
End With
For i = 1 To Range("ModelRange").Rows.Count
MsgBox Worksheets(ModelSht).Range("ModelRange").Cells(i, 0)
````````````````````
The error occurs on this last line. Watchlist shows i=1 and
Rows.Count=10 as they should be. I have another version of this
program that is almost exactly the same but doesn't use variables as
worksheet names that works fine. The "ModelRange" is being defined
correctly -- checked that on the spreadsheet -- but the references to
individual cells seems to be where it blows up?
ANY assistance you can offer would be greatly appreciated!
a watered down version (all variables declarations are not listed):
Dim i as integer
Dim PortName As String
Dim ReviewSht As String
Dim ModelSht As String
Dim HoldingsSht As String
Dim Model As Range
PortName = Right(ActiveSheet.Name, Len(ActiveSheet.Name) - 15)
ReviewSht = "Price Weight - " & PortName
ModelSht = "Model Data - " & PortName
HoldingsSht = "Holdings - " & PortName
Application.ScreenUpdating = False
With Worksheets(ModelSht).Range("A9")
Range(.Offset(0, 0), .End(xlDown).End(xlToRight)).Name =
"ModelRange"
End With
For i = 1 To Range("ModelRange").Rows.Count
MsgBox Worksheets(ModelSht).Range("ModelRange").Cells(i, 0)
````````````````````
The error occurs on this last line. Watchlist shows i=1 and
Rows.Count=10 as they should be. I have another version of this
program that is almost exactly the same but doesn't use variables as
worksheet names that works fine. The "ModelRange" is being defined
correctly -- checked that on the spreadsheet -- but the references to
individual cells seems to be where it blows up?
ANY assistance you can offer would be greatly appreciated!