sourabh_ajmera
New Member
- Joined
- Jul 17, 2014
- Messages
- 36
Hello Everybody,
In another post I received help from @Rihabr & @Scott on how to find text in a specific range. (http://www.mrexcel.com/forum/excel-questions/798738-how-find-text-specific-range.html)
Currently, I am working on an excel sheet where I have to search for a specific 'Date' in row one and get the column letter of that column
My steps are:
In sheet 1
1. Find a specific day (from the above link)
2. Get the date corresponding to the 'day' in step 1
In sheet2
3. Use the date in step 2 to find it in another sheet in the same workbook. (always in row 1 - as headers)
4. Get the 'date' column letter (e.g: Column 1 is Column A, Column 2 is Column B and so on)
Here is my code:
Sub test()
'Find the specific day
Dim c As Range
Dim CellAdd As String
Set c = Range("C1:C7").Find("Friday")
CellAdd = c.Address(0, 0)
'Find the corresponding date to the day
Dim FriDate As String
FriDate = Range(CellAdd).Offset(0, -1).Value
'Find the Column letter corresponding to the date in sheet2
Sheets("sheet2").Select
Dim FindFriDate As Range
Dim FriDateCol As Long
Dim FriDatetxt As String
Set FindFriDate = Rows(1).Find(What:=FriDate, LookIn:=xlValues, LookAt:=xlWhole) <---- FriDate is not being read.
FriDateCol = FindFriDate.Column
FriDatetxt = Replace(Cells(1, FriDateCol).Address(False, False), "1", "")
End Sub
I have also tried something with direct date like;
Set FindFriDate = Rows(1).Find(What:="8/8/2014", LookIn:=xlValues, LookAt:=xlWhole) <---- This also being not read
Please help me with my code. I am beginer so I tend to miss small things.
Thank You in advance and feel free to ask any questions you have.
In another post I received help from @Rihabr & @Scott on how to find text in a specific range. (http://www.mrexcel.com/forum/excel-questions/798738-how-find-text-specific-range.html)
Currently, I am working on an excel sheet where I have to search for a specific 'Date' in row one and get the column letter of that column
My steps are:
In sheet 1
1. Find a specific day (from the above link)
2. Get the date corresponding to the 'day' in step 1
In sheet2
3. Use the date in step 2 to find it in another sheet in the same workbook. (always in row 1 - as headers)
4. Get the 'date' column letter (e.g: Column 1 is Column A, Column 2 is Column B and so on)
Here is my code:
Sub test()
'Find the specific day
Dim c As Range
Dim CellAdd As String
Set c = Range("C1:C7").Find("Friday")
CellAdd = c.Address(0, 0)
'Find the corresponding date to the day
Dim FriDate As String
FriDate = Range(CellAdd).Offset(0, -1).Value
'Find the Column letter corresponding to the date in sheet2
Sheets("sheet2").Select
Dim FindFriDate As Range
Dim FriDateCol As Long
Dim FriDatetxt As String
Set FindFriDate = Rows(1).Find(What:=FriDate, LookIn:=xlValues, LookAt:=xlWhole) <---- FriDate is not being read.
FriDateCol = FindFriDate.Column
FriDatetxt = Replace(Cells(1, FriDateCol).Address(False, False), "1", "")
End Sub
I have also tried something with direct date like;
Set FindFriDate = Rows(1).Find(What:="8/8/2014", LookIn:=xlValues, LookAt:=xlWhole) <---- This also being not read
Please help me with my code. I am beginer so I tend to miss small things.
Thank You in advance and feel free to ask any questions you have.