VBA search column name

negi

Board Regular
Joined
Apr 16, 2009
Messages
87
Hi expert, im using this code need your help if we can search value from a range.

Sub Demo()
Dim ws As Worksheet
Dim table As ListObject
Dim lstrow As ListRow
Dim r As Long
Dim n As Long
Dim e As Long
Dim strSearch As String
Dim invoice As Range
Dim Cases_sold As Range
Dim rate As Range
Dim a As Range
Dim b As Range
Dim c As Range
' strSearch = "invoice"

Set invoice = Sheet1.Rows(1).Find(what:="Invoice", LookIn:=xlValues, _
lookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
'--


Set Cases_sold = Sheet1.Rows(1).Find(what:="cases_sold", LookIn:=xlValues, _
lookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
'---

Set rate = Sheet1.Rows(1).Find(what:="rate", LookIn:=xlValues, _
lookAt:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False)
'----
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
What value you were talking about?

The code will find cells where word Invoice, cases_sold and rate located as range in row 1 where they are named as the words themselves.

Therefore, if you are looking for cell address, then invoice.Address will give the address for example.
 
Upvote 0
What value you were talking about?

The code will find cells where word Invoice, cases_sold and rate located as range in row 1 where they are named as the words themselves.

Therefore, if you are looking for cell address, then invoice.Address will give the address for example.
Thanks .
i need to pick word from range instead of Invoice, cases_sold and rate.
 
Upvote 0
the range value will get the result you're looking for :)
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,249
Members
449,075
Latest member
staticfluids

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