Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Return of row and column

I need some code that will return to a variable, the row
and column of my selection. I have a worksheet with over
1500 rows and 1200 columns, I also have a userform with a
single textbox and a command button. The user can enter
anything in the box (date, name, phone number, etc). When
the button is clicked I want the worksheet to be searched
and when a match is found I want the row and column of the
match to be returned to a variable in the VB code. I have
the userform designed and the search code is all working
ok. I just need the code for the second part of my
project. Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Return of row and column

Dim rw as Long, col as Long
rw = ActiveCell.Row
col = ActiveCell.Column

--
Regards,
Tom Ogilvy

"Gerry" wrote in message
...
I need some code that will return to a variable, the row
and column of my selection. I have a worksheet with over
1500 rows and 1200 columns, I also have a userform with a
single textbox and a command button. The user can enter
anything in the box (date, name, phone number, etc). When
the button is clicked I want the worksheet to be searched
and when a match is found I want the row and column of the
match to be returned to a variable in the VB code. I have
the userform designed and the search code is all working
ok. I just need the code for the second part of my
project. Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Return of row and column

Thanks Tom, now I need to take this rw and col and tell
the application where to begin its execution.

I have Set AddressRng = Worksheets("Sheet4").Range(rw, col)
but I get an run time error 1004. I'm assuming it has to
do with the Range(rw,col) statement. Do you know how this
Range should be specified?

Thanks
-----Original Message-----
Dim rw as Long, col as Long
rw = ActiveCell.Row
col = ActiveCell.Column

--
Regards,
Tom Ogilvy

"Gerry" wrote in

message
...
I need some code that will return to a variable, the row
and column of my selection. I have a worksheet with over
1500 rows and 1200 columns, I also have a userform with

a
single textbox and a command button. The user can enter
anything in the box (date, name, phone number, etc).

When
the button is clicked I want the worksheet to be

searched
and when a match is found I want the row and column of

the
match to be returned to a variable in the VB code. I

have
the userform designed and the search code is all working
ok. I just need the code for the second part of my
project. Thanks



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Return of row and column

Gerry,

You use row and column numbers with the Cells property, not the
Range property. So,

Set AddressRng = Worksheets("Sheet4").Cells(rw, col)


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Gerry" wrote in message
...
Thanks Tom, now I need to take this rw and col and tell
the application where to begin its execution.

I have Set AddressRng = Worksheets("Sheet4").Range(rw, col)
but I get an run time error 1004. I'm assuming it has to
do with the Range(rw,col) statement. Do you know how this
Range should be specified?

Thanks
-----Original Message-----
Dim rw as Long, col as Long
rw = ActiveCell.Row
col = ActiveCell.Column

--
Regards,
Tom Ogilvy

"Gerry" wrote in

message
...
I need some code that will return to a variable, the row
and column of my selection. I have a worksheet with over
1500 rows and 1200 columns, I also have a userform with

a
single textbox and a command button. The user can enter
anything in the box (date, name, phone number, etc).

When
the button is clicked I want the worksheet to be

searched
and when a match is found I want the row and column of

the
match to be returned to a variable in the VB code. I

have
the userform designed and the search code is all working
ok. I just need the code for the second part of my
project. Thanks



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Return of row and column

Hi, this only gives me the location of my cursor not the
location of my find. Sorry I should have been more clear
as to what I need.

Let's say the user inputs "Tom" to a userform and hits
enter, I have the code to search through the worksheet to
find Tom, now I need the code to return the row and column
of that match to a variable or two variables. I will then
use this row and column in the next part of my code.

Does this make sense?

-----Original Message-----
Dim rw as Long, col as Long
rw = ActiveCell.Row
col = ActiveCell.Column

--
Regards,
Tom Ogilvy

"Gerry" wrote in

message
...
I need some code that will return to a variable, the row
and column of my selection. I have a worksheet with over
1500 rows and 1200 columns, I also have a userform with

a
single textbox and a command button. The user can enter
anything in the box (date, name, phone number, etc).

When
the button is clicked I want the worksheet to be

searched
and when a match is found I want the row and column of

the
match to be returned to a variable in the VB code. I

have
the userform designed and the search code is all working
ok. I just need the code for the second part of my
project. Thanks



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Return of row and column

The assumption was that your find code activates the found cell.

Worksheets("Sheet1").Activate
Cells.Find(What:="Tom").Activate

or

Worksheets("Sheet1").Activate
Cells.Find(What:=Userform1.Textbox1.Text).Activate

is what people usually come up with. So rw = ActiveCell.row works fine.

Without seeing your find/search code, it would be difficult to tell you
specifically how to get the row and column. but it is also hard to see how
your find code could work and you not know everything you need to know about
where it was found.

Post your code and perhaps I can give you a better answer.

--
Regards,
Tom Ogilvy



"Gerry" wrote in message
...
Hi, this only gives me the location of my cursor not the
location of my find. Sorry I should have been more clear
as to what I need.

Let's say the user inputs "Tom" to a userform and hits
enter, I have the code to search through the worksheet to
find Tom, now I need the code to return the row and column
of that match to a variable or two variables. I will then
use this row and column in the next part of my code.

Does this make sense?

-----Original Message-----
Dim rw as Long, col as Long
rw = ActiveCell.Row
col = ActiveCell.Column

--
Regards,
Tom Ogilvy

"Gerry" wrote in

message
...
I need some code that will return to a variable, the row
and column of my selection. I have a worksheet with over
1500 rows and 1200 columns, I also have a userform with

a
single textbox and a command button. The user can enter
anything in the box (date, name, phone number, etc).

When
the button is clicked I want the worksheet to be

searched
and when a match is found I want the row and column of

the
match to be returned to a variable in the VB code. I

have
the userform designed and the search code is all working
ok. I just need the code for the second part of my
project. Thanks



.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Return value from specific column if not in new column previously JDub Excel Worksheet Functions 1 September 25th 09 08:23 AM
Return column number from column header text Roger[_3_] Excel Discussion (Misc queries) 4 February 14th 08 09:40 PM
Return text in Column A if Column B and Column K match jeannie v Excel Worksheet Functions 4 December 13th 07 07:36 PM
Find max value in one column and return the value of corrosponding cell in different column [email protected] Excel Worksheet Functions 5 October 16th 07 12:33 PM
LOOKUP and return the column heading for IF/THEN return for False NN Excel Discussion (Misc queries) 1 October 6th 06 11:24 AM


All times are GMT +1. The time now is 07:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"