Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Use row number in spreadsheet as variable in macro

Try something like this

Sub Test()
Dim FoundCell As Range
Dim strRowNumber As Long
With Range("A:A")
Set FoundCell = .find(What:="112", LookAt:=xlWhole)
If FoundCell Is Nothing Then
MsgBox "nothing found"
Else
strRowNumber = FoundCell.Row
MsgBox strRowNumber
End If
End With
End Sub


--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"captbluefin" wrote in message ...
I am using FIND in a macro to select a specific piece of data in a
speadsheet. I then wish to select that row of data to copy and paste
elsewhere. I need to be able to assign the row number to a variable.

Specifically: In a form we enter a sample id number. When the
"Continue" command button is pressed, a macro is invoked that selects a
worksheet that contains many lab id numbers - each lab id number is in
its own row with a bunch of other information pertaining to that lab id
number on the same row.

In the macro, I want to be able to assign the row number where the lab
id is found to a variable.

Let's call the variable strRowNumber. How can I syntactically say

strRowNumber = the row number where the lab id is found

so that the variable contains the row number where the lab id was found
on the workshhet??

Any help would be greatly appreciated. I'm driving myself nuts.

Thanks, Capt. Bluefin



------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~ View and post usenet messages directly from http://www.ExcelForum.com/



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
Macro - Formula RC[?] with ? being a variable number steven.holloway Excel Discussion (Misc queries) 5 July 18th 08 10:07 AM
Loop Macro a variable number of times thesaxonuk Excel Discussion (Misc queries) 11 October 31st 06 06:05 PM
Macro - Using a variable number of columns in a Range stumped Excel Discussion (Misc queries) 2 October 3rd 06 08:13 PM
How do I set a macro to print variable number of pages in excel? Livio Excel Discussion (Misc queries) 1 July 30th 05 12:15 AM
Question: Macro overloading, passing variable number of arguments Frederik Romanov Excel Programming 1 July 8th 03 02:51 PM


All times are GMT +1. The time now is 11:15 AM.

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

About Us

"It's about Microsoft Excel"