route217
asked on
macro to insert headers
Hi Expertrs
Need a macro to insert headers ONE ROW above (that is miss one row then add the table header)....i.e. TABLE ONE: BREAKDOWN BY.....Etc as shown in the blank attachment........as shown...the size of the table can vary........
HEADERS.xlsx
Need a macro to insert headers ONE ROW above (that is miss one row then add the table header)....i.e. TABLE ONE: BREAKDOWN BY.....Etc as shown in the blank attachment........as shown...the size of the table can vary........
HEADERS.xlsx
Can you show me how does you want to see your output..??
ASKER
Hi Suarbs
The output should be add the TABLE ONE: BREAKDOWN header above each of the tables. i.e. find Ice cream and miss one row and add the header TABLE ONE:
Repeat the steps for other tables.....find banana and miss one row and add header TABLE TWO: BREAKDOWN
etc.............the attachment shows the finished product........so if rows 2,17,27 and 41 where not there that would be the starting point.......ADD theses rows we have the finished product.
The output should be add the TABLE ONE: BREAKDOWN header above each of the tables. i.e. find Ice cream and miss one row and add the header TABLE ONE:
Repeat the steps for other tables.....find banana and miss one row and add header TABLE TWO: BREAKDOWN
etc.............the attachment shows the finished product........so if rows 2,17,27 and 41 where not there that would be the starting point.......ADD theses rows we have the finished product.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks once again
ASKER
modified the following vba code...........
Option Explicit
Sub Cap_Table()
Application.ScreenUpdating
Dim i As Integer, lstrow1 As Integer, TotRow As Integer, TotCol As Integer, lstrow2 As Integer
Dim ws1 As Worksheet
Dim rngX As Range
Application.ScreenUpdating
Application.DisplayAlerts = False
Set ws1 = ActiveSheet
Set rngX = ws1.Range("A:A").Find("Gra
If Not rngX Is Nothing Then
ws1.Rows(Mid(rngX.Address,
End If
Set rngX = ws1.Range("A:A").Find("Lab
If Not rngX Is Nothing Then
TotRow = Mid(rngX.Address, InStr(2, rngX.Address, "$") + 1, 3)
TotCol = ws1.Cells(Mid(rngX.Address
lstrow1 = ws1.Cells(65536, "A").End(xlUp).Row
ws1.Rows(TotRow & ":" & lstrow1).Copy
ws1.Range("A" & lstrow1 + 6).PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
Selection.NumberFormat = "0.00"
lstrow2 = ws1.Cells(65536, "A").End(xlUp).Row
ws1.Cells(lstrow1 + 4, 1) = "Current Capacity Data"
ws1.Cells(lstrow1 + 6, 1) = "HOFs"
ws1.Cells(lstrow1 + 6, 4) = "Temp"
For i = 1 To TotCol
ws1.Cells(lstrow1 + 4, 1).Interior.Color = RGB(250, 192, 144)
ws1.Cells(lstrow1 + 4, 1).Font.Bold = True
ws1.Cells(lstrow1 + 4, 2).Interior.Color = RGB(250, 192, 144)
ws1.Cells(lstrow1 + 4, 2).Font.Bold = True
ws1.Cells(lstrow1 + 6, i).Interior.ColorIndex = 41
ws1.Cells(lstrow1 + 6, i).Font.Bold = True
ws1.Cells(lstrow2, i).Interior.ColorIndex = 41
ws1.Cells(lstrow2, i).Font.Bold = True
Next
End If
Application.ScreenUpdating
Application.DisplayAlerts = True
End Sub