ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Find A value in a column and count the rows (https://www.excelbanter.com/excel-programming/414369-find-value-column-count-rows.html)

KWhamill

Find A value in a column and count the rows
 
I am not making this up I have been asked to do the following: Create in VBA
such that the code finds a specified date in Column A and then counts the
Number of rows to it and then plugs that number into an Hlookup. So then the
Hlookup goes to that row and gets the appropriate value. so far i have the
following:
Step 1: Find in Column A the specified date that might be typed in a cell
somewhere else, say on the target spreadsheet. I'm sure i can do this part.
Step 2: count the rows from the top in which the date is found? actually now
that i think about it count the rows from the top of the Hlookup. I'm sure i
don't know how to do this.
Step 3 how do i plug this number into an Hlookup. do i just set the row
count equal to r and then stick r in the formula?
if anyone has anygood ideas or better ways of doing the same I'm all ears.
Thank you,
Karl

joel

Find A value in a column and count the rows
 

set c = Columns("A").Find(what:="abc",lookin:=xlvalues,loo kat:=xlwhole_
if c is nothing then
msgbox("did not find abc")
else
msgbox("found abc at row : " & c.row)
end if

"KWhamill" wrote:

I am not making this up I have been asked to do the following: Create in VBA
such that the code finds a specified date in Column A and then counts the
Number of rows to it and then plugs that number into an Hlookup. So then the
Hlookup goes to that row and gets the appropriate value. so far i have the
following:
Step 1: Find in Column A the specified date that might be typed in a cell
somewhere else, say on the target spreadsheet. I'm sure i can do this part.
Step 2: count the rows from the top in which the date is found? actually now
that i think about it count the rows from the top of the Hlookup. I'm sure i
don't know how to do this.
Step 3 how do i plug this number into an Hlookup. do i just set the row
count equal to r and then stick r in the formula?
if anyone has anygood ideas or better ways of doing the same I'm all ears.
Thank you,
Karl



All times are GMT +1. The time now is 10:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com