Quantcast
Channel: Excel Help Forum - Excel Programming / VBA / Macros
Viewing all articles
Browse latest Browse all 50139

Getting "Object variable or With block variable not set" error with Find function

$
0
0
I am trying to allow a user to double-click on a cell in column 2 on Sheet1 and it will take them to a cell on a different worksheet where the date matches the date that is on the same row in column 1 on Sheet1. Code is below:

Code:

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  Dim fRow As Integer
  Dim fSheet, fDate As Variant
 
  If (Target.Row < 3) Or (Target.Font.FontStyle = "Bold") Or (Cells(2, Target.Column).Value <> "Notes") Then Exit Sub
  fSheet = Sheet1.Cells(1, Target.Column).Value
  fDate = Sheet1.Cells(Target.Row, 1).Value
  Sheets(fSheet).Activate
  fRow = ActiveSheet.Range("A3:A20000").Find(fDate, , xlValues).Row
  Sheets(fSheet).Cells(fRow, 1).Select
  Application.Goto ActiveCell, Scroll:=True
 
End Sub

I am getting the error on the line with the range.find. I've tried multiple ways to write it but keep getting the error.

Viewing all articles
Browse latest Browse all 50139

Trending Articles