![]() |
Inserting Rows in multiple areas
Column "A" is where the the data needs to be inserted. There are 3
groups of data on top of each other. For instance item #s are rows 1-3. Other information is 4-6. Misc info is 7-9. If the item numbers were "A", "C" and "D" and I wanted to add item "B". Keeping in mind that Row 1 relates to 4 and 6 plus I need an additional space in each section. So in this case 2 woudl move down and become 3 to place "B". Since 4 became 5, 5 woudl move down to become 6 and so on. I hope I am making myself clear. Thanks, Jay |
Inserting Rows in multiple areas
On Jan 24, 10:31*am, jlclyde wrote:
Column "A" is where the the data needs to be inserted. *There are 3 groups of data on top of each other. *For instance item #s are rows 1-3. *Other information is 4-6. *Misc info is 7-9. *If the item numbers were "A", "C" and "D" and I wanted to add item "B". * Keeping in mind that Row 1 relates to 4 and 6 plus I need an additional space in each section. *So in this case 2 woudl move down and become 3 to place "B". *Since 4 became 5, 5 woudl move down to become 6 and so on. *I hope I am making myself clear. Thanks, Jay In case anyone was interested, I have figured it out on my own. Here is the code. Sub InsertChristmasCard() Dim x As Variant, set1 As Long, s As String Dim Srow As Integer s = InputBox("Enter new Christmas Number") If s = "" Then Exit Sub Application.ScreenUpdating = False set1 = Cells(Range("F2").Value - 1, 1).Row x = Application.Match(s, Range("A4:A" & set1), 1) 'assumes names in order starting in row 2 If IsError(x) Then 'new name will be first set1 = 4 Else set1 = x + 4 End If Rows(set1).Insert Cells(set1, 1) = s Srow = Cells.Find(s).Row Rows(Srow - Range("F1").Value + Range("F2").Value).Insert Rows(Srow - Range("F1").Value + Range("F3").Value).Insert Application.ScreenUpdating = True End Sub F2 =ROW("The first cell in teh 2nd group") F3 =ROW("The first cell in the 3rd group") Jay |
All times are GMT +1. The time now is 02:30 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com