Need help with VBA to find cell with text, then find adjacent cell, then merge the two

MrsGarrett

New Member
Joined
Sep 24, 2014
Messages
3
Hi! I am working on some code to do a bunch of conditional formatting in a spreadsheet. Right now I have the vba to find a cell with a certain word in it: For Each C In oSheet.Range("A1:" & Chr(iNumCols + 64) & rs.RecordCount + 1).Cells If C.Value = "BA-Coordination and Impact Analysis Technical Support: S. King Street Vicinity to Roy Street - Central Waterfront Viaduct Replacement" What I need to do is find that cell, locate the adjacent cell, and then merge the two. Then I will need to format the merged cell, but I haven't gotten that far yet. Also, I am doing this from Access. I don't know how much that matters, but that is what is happening. Any help will be greatly appreciated! (I can't seem to use the carriage return in this post, so I apologize for how this runs together)
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi! I am working on some code to do a bunch of conditional formatting in a spreadsheet. Right now I have the <acronym title="visual basic for applications" style="border-width: 0px 0px 1px; border-bottom-style: dotted; border-bottom-color: rgb(0, 0, 0); cursor: help; color: rgb(51, 51, 51); background-color: rgb(250, 250, 250);">vba</acronym> to find a cell with a certain word in it

Code:
For Each C In oSheet.Range("A1:" & Chr(iNumCols + 64) & rs.RecordCount + 1).Cells
    If C.Value = "BA-Coordination and Impact Analysis Technical Support: S. King Street Vicinity to Roy Street - Central Waterfront Viaduct Replacement"

What I need to do is find that cell, locate the adjacent cell, and then merge the two. Then I will need to format the merged cell, but I haven't gotten that far yet. Also, I am doing this from Access. I don't know how much that matters, but that is what is happening. Any help will be greatly appreciated! (I can't seem to use the carriage return in this post, so I apologize for how this runs together)

---All I did was format it---
 
Upvote 0
You mean you just selected the cells and clicked "merge"? Because I need to have it do that automatically. My user is creating a report and it has to have all the formatting done automatically from Access. Having the user select both cells and click "merge" is not an option.
 
Upvote 0
You mean you just selected the cells and clicked "merge"? Because I need to have it do that automatically. My user is creating a report and it has to have all the formatting done automatically from Access. Having the user select both cells and click "merge" is not an option.


No, I mean all I did was format the post because you mentioned difficulty with carriage returns and neglected code tags. Sorry for confusion.
 
Upvote 0

Forum statistics

Threads
1,215,055
Messages
6,122,902
Members
449,097
Latest member
dbomb1414

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