Quantcast
Channel: VBForums - Visual Basic .NET
Viewing all articles
Browse latest Browse all 27386

vba code for excel

$
0
0
I Know this forum is for VB.net stuff, but I have a simple question and did not feel like signing up for a VBA forums page, but will if I need too...

In excel, I want to be able to programmatically merge the cells in a row based on the fact that the word "Laboratory" is in any cell in that row, and I want the merge to start at that cell containing the word "Laboratory" and go to the right hand side of the selection. Here is what I have so far which will loop through all of the cells inside of the selection.

Code:

For Each cell In selectedRange ' loop through all the cells in the selection
    If InStr(cell.value, "Laboratory") > 0 Then ' if this is > 1, this is the cell I am looking for
     
       
    End If
Next

this line is close to what I need, but the offset changes:

Code:

Range(cell, cell.Offset(1, 0)).Merge

Viewing all articles
Browse latest Browse all 27386


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>