Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-14-2014, 05:26 AM
gogita_79 gogita_79 is offline need macro insert row under specific data Windows 8 need macro insert row under specific data Office 2013
Novice
need macro insert row under specific data
 
Join Date: Sep 2014
Posts: 11
gogita_79 is on a distinguished road
Default need macro insert row under specific data


hi, I need macro that helps me insert one blank row under data 1410.01 lighted yellow. thanks
Attached Images
File Type: png Capture.PNG (22.8 KB, 18 views)
Reply With Quote
  #2  
Old 09-14-2014, 09:29 AM
excelledsoftware excelledsoftware is offline need macro insert row under specific data Windows 7 64bit need macro insert row under specific data Office 2003
IT Specialist
 
Join Date: Jan 2012
Location: Utah
Posts: 455
excelledsoftware will become famous soon enough
Default

This simple snippet should do it. Just set the EvalCol to the column letter containing Gel and 1410.01.
Code:
Sub InsertRow()
  Dim CheckRow As Long, EndRow As Long, CheckString As String, EvalCol As String
  
  
  EvalCol = "G" 'Set this to the column you need to evaluate keep it in quotes
  

  EndRow = Range(EvalCol & 50000).End(xlUp).Row
  
  For CheckRow = 2 To EndRow
    CheckString = Range(EvalCol & CheckRow).Value
    If CheckString = "1410.01" Then
      Range(CheckRow + 1 & ":" & CheckRow + 1).Insert
    End If
  Next CheckRow
  
End Sub
Reply With Quote
  #3  
Old 09-15-2014, 01:48 AM
macropod's Avatar
macropod macropod is offline need macro insert row under specific data Windows 7 64bit need macro insert row under specific data Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

An alternative approach:
Code:
Sub InsertRows()
Dim lRow As Long, i As Long
With ThisWorkbook.Worksheets("Sheet1").UsedRange
  For i = .Cells.SpecialCells(xlCellTypeLastCell).Row To 1 Step -1
    If .Range("G" & i).Value = "1410.01" Then
       While .Range("G" & i + 1).Value <> ""
          .Range("G" & i + 1).EntireRow.Insert
       Wend
     End If
  Next
End With
End Sub
This approach ensures there is only one blank row (i.e. it won't insert one if there already is one).

Note: The code assumes the "1410.01" is in column G. Change the 'G' in the three '.Range("G"' references to suit.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro Needed to bold specific lines and Macro to turn into CSV anewteacher Word VBA 1 05-28-2014 03:59 PM
need macro insert row under specific data how to create menu shortcut to insert specific picture msworddave Word 1 05-08-2013 02:00 AM
Linking: Insert > Pictures to a specific folder location hockfam PowerPoint 0 11-08-2012 08:09 PM
Match two sets of data and display specific data lolly150 Excel 1 05-14-2012 10:33 PM
Insert an item to excel specific cell apjneeraj Excel 0 01-18-2011 03:39 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 10:43 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft