matching/finding text in 2 cells in worksheet

Rasberry

Board Regular
Joined
Aug 11, 2002
Messages
195
Office Version
  1. 365
I want to find the text in a worksheet that resides in two cells (it is a column heading split into 2 cells). What code should I use to find the text string split into 2 cells? Any insight would be helpful! Thanks, Rasberry
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
If you mean find as in using the find function it might look something like:

=FIND("ab", D15&E15)

Where the & concatanates (joins) the two strings.

If you mean something else, I'm sure concatanation is part of the answer.

Hope this helps,

K
 
Upvote 0
I don't understand how that would work. I need to find the words "Rtn on Equity" in a spreadsheet, and "Rtn on" is in one cell, and "Equity" is in the cell below it.
 
Upvote 0
Thanks for responding. I am actually writing VBA code. I am trying to write code that searches the spreadsheet for the two consecutive cells and then it will perform another task after it finds those contiguous cells.
 
Upvote 0
If the cells are in the same row, this might work (untested):
Code:
'
' -Code assumes columns A and B are the headings
'
Sub FindEm()

dim i as long
dim iFound as long
dim sTemp as string

for i = 1 to 1000 'Your first row to your last row
   sTemp = Range("A" & i).value & " " & Range("B" & i).value
   if sTemp = "Rtn on Equity" Then
      iFound = i
      Exit For
   end if
next

'Continue on from here with i as the row number with the found heading

End Sub

This could also be converted into a function and called from a main subroutine.

K
 
Upvote 0
Thanks! I haven't got it to work, yet. But it is something to start with. I'm working on getting the coding that will cycle through a range rather than just two columns. Basically the spreadsheet. But this is very helpful!
 
Upvote 0

Forum statistics

Threads
1,214,657
Messages
6,120,777
Members
448,991
Latest member
Hanakoro

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