0
Thanks

A few words of thanks would be greatly appreciated.

Excel - Find a variable in a selection




Issue


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  
          
    Columns("A:A").Select  
    Selection.Find(What:=aVab, After:=ActiveCell, LookIn:=xlValues, LookAt _  
    :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _  
    False, MatchFormat:=False).Activate  
    ActiveCell.Select

Solution


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   
c.Select   

End If   

Next c  

Note


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

A few words of thanks would be greatly appreciated.

Ask a question
CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Published by . Latest update on by deri58.

This document, titled "Excel - Find a variable in a selection," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (https://ccm.net/).

0 Comments