I'm looking to insert a row, a separator if you will, after "TotSupply" is found in column B. The text appears many times but only in column B. I have attached the spreadsheet. Thank you in advance for your help.
I'm looking to insert a row, a separator if you will, after "TotSupply" is found in column B. The text appears many times but only in column B. I have attached the spreadsheet. Thank you in advance for your help.
Try this:
How to install your new code![]()
Option Explicit Sub foo() Dim lr As Long lr = Range("B" & Rows.Count).End(xlUp).Row Dim i As Long Application.ScreenUpdating = False For i = 1 To lr If Range("B" & i) = "TotSupply" Then Range("B" & i + 1).EntireRow.Insert End If Next i Application.ScreenUpdating = True MsgBox ("complete") End Sub
- Copy the Excel VBA code
- Select the workbook in which you want to store the Excel VBA code
- Press Alt+F11 to open the Visual Basic Editor
- Choose Insert > Module
- Edit > Paste the macro into the module that appeared
- Close the VBEditor
- Save your workbook (Excel 2007+ select a macro-enabled file format, like *.xlsm)
To run the Excel VBA code:
- Press Alt-F8 to open the macro list
- Select a macro in the list
- Click the Run button
Alan עַם יִשְׂרָאֵל חַי
Change an Ugly Report with Power Query
Database Normalization
Complete Guide to Power Query
Man's Mind Stretched to New Dimensions Never Returns to Its Original Form
Try this.
![]()
Sub InsertRow() Dim rng As Range Application.ScreenUpdating = False Set rng = Range("B6") While rng.Value <> "" rng.Offset(1).EntireRow.Insert Set rng = rng.Offset(6) Wend Application.ScreenUpdating = True End Sub
If posting code please use code tags, see here.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks