#1
|
|||
|
|||
VBA: Find a column by its date
Hi,
I am just learning Excel and VBA again after some years with other tools. Now I have a task that I have already solved to a good part. Right now, I have the value I want in a variable and I just have to paste that in the "adressee_table" in a specific row (fixed value depending on the type of value) and a specific column (dependent on the date, the date is across the entire table in line 3). I always have yesterday's data, so my macro should always look for the column with yesterday's date in line 3 and just paste the variable in that cell. I guess I need that FIND command, but I don't know the exact syntax and what I have to write in the parameters and I haven't yet got fluent in using the integrated help. Can anybody tell me how to do that? Thanks a lot! Best regards, Officer_Bierschnitt |
#2
|
||||
|
||||
Here's a trivial demonstration of using the Find command to find something in row 3 and return the corresponding value from row 2:
Code:
Sub Demo() Dim xlRng As Range, StrTxt As String StrTxt = InputBox("Please input the text to find") With ActiveSheet Set xlRng = .Range("3:3").Find(What:=StrTxt, LookIn:=xlValues, _ LookAt:=xlWhole, SearchOrder:=xlByColumns, MatchCase:=True, SearchFormat:=False) If Not xlRng Is Nothing Then MsgBox "Row 3: " & StrTxt & " found in column " & xlRng.Column & vbCr & _ "Row 2: " & .Cells(2, xlRng.Column).Text & " found in column " & xlRng.Column End If End With End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Which Office program to use to find a day/date | gblosser | Office | 5 | 01-17-2015 05:44 AM |
Inconsistent Duration column for the same date ranges | ravl13 | Project | 3 | 07-28-2014 05:16 PM |
Automatically enter date into a column and make that column read only | Mr Davo | Excel | 1 | 10-29-2012 01:07 AM |
Displaying Work Week instead of date in a column. | whitney07 | Project | 1 | 07-05-2012 02:27 PM |
Use SMALL or LARGE to find date | udea | Excel | 4 | 05-02-2011 09:08 PM |