![]() |
Inserting a Row after finding a Name in colum
I am having a problem inserting a Row into a Colum with Names, the Colum also
has empty Cells, I have to find Name and then insert a row over the Name before continuing. I am using the visuel Basic with excel 2007 Thanks |
Inserting a Row after finding a Name in colum
See if the following example helps.
Sub Macro1() Dim rngColumn As Range Dim foundCell As Range Dim findWhat As String With Sheets("Sheet1") Set rngColumn = .Columns("C") End With 'InputBox to get the value to find findWhat = InputBox("enter name to find") 'You may need to alter the parameters 'in the Find depending on your needs. 'Example xlPart only has to have the 'required value somewhere in the cell 'whereas xlWhole, the entire cell must 'match the required value exactly. Set foundCell = rngColumn.Find(What:=findWhat, _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False, _ SearchFormat:=False) If Not foundCell Is Nothing Then foundCell.EntireRow.Insert End If End Sub -- Regards, OssieMac "Dunomuch" wrote: I am having a problem inserting a Row into a Colum with Names, the Colum also has empty Cells, I have to find Name and then insert a row over the Name before continuing. I am using the visuel Basic with excel 2007 Thanks |
Inserting a Row after finding a Name in colum
"OssieMac" wrote: See if the following example helps. Sub Macro1() Dim rngColumn As Range Dim foundCell As Range Dim findWhat As String With Sheets("Sheet1") Set rngColumn = .Columns("C") End With 'InputBox to get the value to find findWhat = InputBox("enter name to find") 'You may need to alter the parameters 'in the Find depending on your needs. 'Example xlPart only has to have the 'required value somewhere in the cell 'whereas xlWhole, the entire cell must 'match the required value exactly. Set foundCell = rngColumn.Find(What:=findWhat, _ LookIn:=xlFormulas, _ LookAt:=xlPart, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False, _ SearchFormat:=False) If Not foundCell Is Nothing Then foundCell.EntireRow.Insert End If End Sub -- Regards, OssieMac "Dunomuch" wrote: I am having a problem inserting a Row into a Colum with Names, the Colum also has empty Cells, I have to find Name and then insert a row over the Name before continuing. I am using the visuel Basic with excel 2007 Thanks thanks for the answer , im afraid i did not give a precise question, in Column A i have about 380 names with empty cells inbetween from a SAP list, with other data in 2 other Columns, B and C in Column A the only value in all Names is "," and the empty has to be directly over the Name so that i can later build a Table by i think transponding?? |
All times are GMT +1. The time now is 12:01 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com