[h=1]VBA runtime error '6': overflow [code here][/h]I have 2 worksheets giving me the same error. This is part of the code. What do I need to change here in order to get rid of this error? Thanks in advance!
code 1:
Code
Dim row As Integer
Dim LastRow As Integer
LastRow = Sheets("worksheetname").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
Range(Cells(3, 1), Cells(LastRow, 41)).ClearFormats
Range(Cells(3, 1), Cells(LastRow, 41)).Locked = False
If LastRow < Cells(LastRow, 1).End(xlDown).row Then
Range(Cells(LastRow + 1, 1), Cells(LastRow, 1).End(xlDown)).Locked = True
Rows(CStr(LastRow + 1) & ":" & CStr(Cells(LastRow, 1).End(xlDown).row)).Hidden = True
End If
Display More
Code 2:
Code
Private Sub SetValidationAndFormatting()
LastRow = SetLastRow("worksheetname")
With Sheets("worksheetname")
.Range(Cells(3, 1), Cells(LastRow_DRC, 7)).Locked = True
If LastRow_DRC < .Cells(LastRow_DRC, 1).End(xlDown).row Then
.Range(.Cells(LastRow_DRC + 1, 1), .Cells(LastRow_DRC, 1).End(xlDown)).Locked = True
.Rows(CStr(LastRow_DRC + 1) & ":" & CStr(.Cells(LastRow_DRC, 1).End(xlDown).row)).Hidden = True
End If
Display More
Code
Private Function SetLastRow(WorksheetName As String) As Integer
SetLastRow = Sheets("Data Role Coverage").Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row
End Function
MODERATOR EDIT
Welcome to OZ Grid
Please use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window.
I’ve added them this time but please comply in the future