Rowland Hamilton
Active Member
- Joined
- Nov 13, 2009
- Messages
- 250
Can anyone explain why this code breaks on row 21,833 after working since row 8? Note: vntMatch is defined as variant and does not change. UsedRange is getting the proper row count (27,852)
Dim vntMatch As Variant
Dim vntMatch As Variant
Code:
vntMatch = Application.Match("Manual", shtCashForecast.Range("7:7"), 0)
If Not IsError(vntMatch) Then
'Loop through Manual column, offsets to start with cell under header.
For Each rCell In shtCashForecast.Range("7:7").Cells(1, vntMatch).Offset(1, 0).Resize(shtCashForecast.UsedRange.Rows.Count, 1).Cells
'Adds validation to Manual column cells if total forecast for row > 0
'Changing offset from -1 to -3 since added 2 columns
If InStr(rCell.Offset(0, -3).Formula, "=") > 0 Then
With rCell.Validation
.Delete
.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
xlBetween, Formula1:="=ManualMonths"
.IgnoreBlank = True
.InCellDropdown = True
.InputTitle = ""
.ErrorTitle = ""
.InputMessage = ""
.ErrorMessage = ""
.ShowInput = True
.ShowError = True
End With
End If
Next
End If