Search a Row starting at Specified Column

cart0250

Active Member
Joined
Jun 24, 2006
Messages
285
Office Version
  1. 2016
Platform
  1. Windows
Hello,

Below searches row 1 for value corresponding to the testData variable.

How could i adapt this to search row 1 beginning at column F (rather than col A)?

I'd like to continue using Find rather than a loop.

VBA Code:
Set d = Sheets("Testing").Rows(1).Find(What:=testData, LookAt:=xlWhole)

Much appreciated.
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
VBA Code:
Set d = Sheets("Testing").Range("F1").Find(What:=testData, LookAt:=xlWhole)
Does the above work?
 
Upvote 0
Try:
VBA Code:
    With Sheets("Testing")
        Set d = .Range("F1", .Cells(1, Columns.Count)).Find(What:=testData, LookAt:=xlWhole)
    End With
Pete's version only looks in F1
 
Upvote 0
The fact that this question has been asks implies that testData might occur more than once in row 1. In case there might possibly be more than one instance in F1 and right, I would suggest a further slight change assuming that you want to be sure to find the first occurrence in the target range.

VBA Code:
With Sheets("Testing")
  Set d = .Range("F1", .Cells(1, Columns.Count)).Find(What:=testData, After:=.Cells(1, Columns.Count), LookAt:=xlWhole, SearchDirection:=xlNext)
End With
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,882
Messages
6,175,165
Members
452,615
Latest member
bogeys2birdies

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