Find Method and Address Property

oric

New Member
Joined
Jul 19, 2005
Messages
36
Hi all,

I have been trying to finish this code for searching for Column descriptions (text in the first few rows) and then using that address as a starting point to loop through the cells in that column. I think I got the searching part down. My only problem now is to use the address property to return the column number so that I can use it in the Worksheets.Cells(#,#) syntax. Here is the code I got so far.

Code:
Sub FindingColumn()
Dim rngLook As Range, rngFound As Range, fndcell As Range
Dim strVal As String
Set rngLook = Worksheets(1).Rows("1:2")
Set rngFound = rngLook.Find(What:=strVal)
If Not rngFound Is Nothing Then
fndcell = rngFound.Address(False, False)
End If
...
...

End Sub


Any suggestions on how to proceed??

many thx's
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Range(mystr).Column Returns the column number.
".Column" can appended to any range to give you the first column in the range.
Code:
Ex: Range("A1:H1").Column
= 1
Code:
Range("H1").Column
= 8

To get the last column you could do somthing like:
Code:
Range("C1:I1").Columns.Count + Range("C1:I1").Column - 1
Which is the number of columns in the range (7) + the number of the left colum(3) minus one becuase the left column is count twice by this addition.
 
Upvote 0

Forum statistics

Threads
1,215,700
Messages
6,126,283
Members
449,308
Latest member
VerifiedBleachersAttendee

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top