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)
 

Some videos you may like

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

NeonRedSharpie

Well-known Member
Joined
Jul 14, 2014
Messages
1,678
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---
 

MrsGarrett

New Member
Joined
Sep 24, 2014
Messages
3
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.
 

NeonRedSharpie

Well-known Member
Joined
Jul 14, 2014
Messages
1,678
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.
 

Watch MrExcel Video

Forum statistics

Threads
1,109,540
Messages
5,529,434
Members
409,876
Latest member
Akash Yadav
Top