gtd526
Well-known Member
- Joined
- Jul 30, 2013
- Messages
- 660
- Office Version
- 2019
- Platform
- Windows
Hello, Just wondering why this gives me an error.
Dim Rng As Range
Dim Rng2 As Range
'this is working because foundRng is = to Rng
Set Rng = ActiveSheet.Range("A3") 'defines date played, define date looking to match
Sheets("Schedule").Select
Set foundRng = Range("1:1").Find(Rng) 'using Row 2 to find Rng(A3)
If foundRng = Rng Then
foundRng.Select
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Copy
Sheets("Favs").Select
Range("A5").Select
ActiveSheet.Paste
Else
End If
'this is NOT working because foundRng is not = to Rng2, I want it to work when they are <>
foundRng = Nothing, because the date doesn't exist in Row 1:1 ?I assume? This is where I get the error (object variable or With block variable not set).
I just want it to End If , if the date doesn't exist otherwise do the code.
Set Rng2 = ActiveSheet.Range("A32") 'day after original, define date looking to match
Sheets("Schedule").Select
Set foundRng = Range("1:1").Find(Rng2) 'using Row 2 to find Rng2(A32)
If foundRng = Rng2 Then (error on this line)
foundRng.Select
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Copy
Sheets("Favs").Select
Range("A33").Select
ActiveSheet.Paste
Else
End If
Hopefully this makes sense.
thank you
Dim Rng As Range
Dim Rng2 As Range
'this is working because foundRng is = to Rng
Set Rng = ActiveSheet.Range("A3") 'defines date played, define date looking to match
Sheets("Schedule").Select
Set foundRng = Range("1:1").Find(Rng) 'using Row 2 to find Rng(A3)
If foundRng = Rng Then
foundRng.Select
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Copy
Sheets("Favs").Select
Range("A5").Select
ActiveSheet.Paste
Else
End If
'this is NOT working because foundRng is not = to Rng2, I want it to work when they are <>
foundRng = Nothing, because the date doesn't exist in Row 1:1 ?I assume? This is where I get the error (object variable or With block variable not set).
I just want it to End If , if the date doesn't exist otherwise do the code.
Set Rng2 = ActiveSheet.Range("A32") 'day after original, define date looking to match
Sheets("Schedule").Select
Set foundRng = Range("1:1").Find(Rng2) 'using Row 2 to find Rng2(A32)
If foundRng = Rng2 Then (error on this line)
foundRng.Select
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Copy
Sheets("Favs").Select
Range("A33").Select
ActiveSheet.Paste
Else
End If
Hopefully this makes sense.
thank you