Web Development

General discussion


Visual Basic Search Text and Insert Row

By finnp ·
I need to write a Visual Basic program that will search the Excel sheet for a number and then insert a row where that number occurs. I can write the code to search. I can also write code to insert a row at a specific location. My trouble is with inserting a row that is not known until the search function finds the correct cell.

Thanks for any suggestions!

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by Litehouse In reply to Visual Basic Search Text ...

I believe this short snippet will answer your question.

Option Explicit

Public Sub FindAndInsert()
Const ValueToFind As Integer = 6
Dim rngValue As Range

Set rngValue = Me.Rows.Find(ValueToFind)
End Sub

Related Discussions

Related Forums