Home > Software engineering >  Loop line search specified, when a value is equal to the specified value, insert a column in front
Loop line search specified, when a value is equal to the specified value, insert a column in front

Time:11-11

Pray god give advice or comments!



As shown in figure, loop search, when the value in the cell is BCD, insert a column in front, the result diagram below

CodePudding user response:

 Sub BCDInsertColumn () 
Dim col As Long, lstcol As Long
Const target_row As Long=3 'BCD line

Lstcol=Cells (target_row, Columns. The Count) End (xlToLeft). The Column
For col=lstcol To Step 1-1
If Cells (target_row, col)="BCD" Then
The Columns (col). Insert
End the If
Next col
End Sub
  •  Tags:  
  • VBA
  • Related