unknownymous
Board Regular
- Joined
- Sep 19, 2017
- Messages
- 249
- Office Version
- 2016
- Platform
- Windows
Hi Guys,
Can you help me tweak the code below for below table?
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]No[/TD]
[TD]x[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Sean[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Output Submitted To Department[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Output Submitted To Deparmnt[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Output Sbmitted To Dpartment[/TD]
[/TR]
</tbody>[/TABLE]
-------------------------------------------------------------------
Sub AddRow()
Dim SrchRng As Range, cel As Range
Set SrchRng = Range("B:B")
For Each cel In SrchRng
If InStr(1, cel.Value, "OUTPUT") > 0 Then
cel.Offset(1, 0).EntireRow.Insert
End If
Next cel
End Sub
---------------------------------------------------------------------
The code is working but I wanted to insert a column on the FIRST found "OUTPUT" word in B column and not repetitively add in every word found.
Any help will be much appreciated.
Can you help me tweak the code below for below table?
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]No[/TD]
[TD]x[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Sean[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Output Submitted To Department[/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]Output Submitted To Deparmnt[/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Output Sbmitted To Dpartment[/TD]
[/TR]
</tbody>[/TABLE]
-------------------------------------------------------------------
Sub AddRow()
Dim SrchRng As Range, cel As Range
Set SrchRng = Range("B:B")
For Each cel In SrchRng
If InStr(1, cel.Value, "OUTPUT") > 0 Then
cel.Offset(1, 0).EntireRow.Insert
End If
Next cel
End Sub
---------------------------------------------------------------------
The code is working but I wanted to insert a column on the FIRST found "OUTPUT" word in B column and not repetitively add in every word found.
Any help will be much appreciated.