Excel - Find a variable in a selection

October 2016


I have data added each day and I was wanting to add a button that basically jumps to todays date and then copies data to the attached row. Copying is fine but so far however I can't even select the date.
Column A has the dates which can change, but will always contain today. C3=Today() . I have tried to set aVab, but I am a complete novice and can't find the answer to this simple query. I seem to always get error 91 object variable not set thingy.

Dim aVab As Date  
    aVab = Range("C3").Value  
    Selection.Find(What:=aVab, After:=ActiveCell, LookIn:=xlValues, LookAt _  
    :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _  
    False, MatchFormat:=False).Activate  


If the date [Today())] will appear in the column one time and you want to select that cell, this will do the trick.
Hope this helps!

Dim aVab   
Dim c As Range   
aVab = Range("C3").Value   

For Each c In Range("A1:A65536")   

If c = aVab Then   

End If   

Next c  


Thanks to Wut Up WutUp for this tip on the forum.

Related :

This document entitled « Excel - Find a variable in a selection » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.