I am tring to find the word "Example" in whole used cells. But the code gives me Runtime Error 1004 “Application-defined or Object-defined error”. I know there is something wrong with the line Range(Cells(1, 1), Cells(lastrow, lastcolumn))
What could it be?
Thanks in advance. Here is the Code:
Dim lastrow as Long
Dim lastcolumn as Long
Dim sclnr as Range
dim aws as WorkSheet
Set aws = Thisworkbook.Sheets("Sheet1")
'Using UsedRange
lastrow = aws.UsedRange.Rows(aws.UsedRange.Rows.Count).Row
lastcolumn = aws.UsedRange.Columns(aws.UsedRange.Columns.Count).Column
'UsedRange works fine no problem with finding last row and column
Set sclnr = aws.Range(Cells(1, 1), Cells(lastrow, lastcolumn)).Find("Example")
'the word Example exits in one of the cells