UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Vba - Set Cell Value Based On Lookup, Office 2013    
 
   
Javiator
post Jul 24 2019, 03:48 PM
Post#1



Posts: 351
Joined: 8-December 09
From: USA


Hello,

My spreadsheet is tracking when video content was last viewed. Column B contains the content's ID, and column M contains the timestamp from the latest viewing. My code below captures the content's ID, and I would like for it also to find the row in column B with this ID, and then input a timestamp in column M of the same row, before saving and closing. Could someone please provide the missing code?
CODE
Sub Button1_Click()

    Dim intEpisodeID As Integer

    With Worksheets("Form")
    
        intEpisodeID = .Range("B9").Value
    
    End With
    
    'ADD TIMESTAMP TO COLUMN M HERE.
    
    ActiveWorkbook.Close SaveChanges:=True

End Sub

Thank you so much!
Go to the top of the page
 
aoh
post Jul 29 2019, 08:19 AM
Post#2



Posts: 1,425
Joined: 20-February 04
From: Dublin, Ireland


Try something like this:

CODE
    xlRow = 1 (change if you have headers)
    xlSheet.Range("B" & xlRow).Select
    Do While Nz(xlSheet.Range("B" & xlRow).Value, 0) = intEpisodeID
        xlRow = xlRow + 1
        xlSheet.Range("B" & xlRow).Select
    Loop
    
    xlSheet.Range("M" & xlRow).Value = Now()


What happens if the Episode Id is not in the list?

--------------------
Anne

Experience is a wonderful thing. It enables you to recognize a mistake when you've just made it again.
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    13th November 2019 - 07:49 AM