Hi,
I was wondering if VBA can workout if a selection is part of a group and if it is can it then ungroup the selection?
I have added my code below,
basically we have a spreadsheet where i need to add various items differing for every project how many items will be needed to add in so have a very basic code to add a new blank item into. I am very new VBA coding... this is basically my 1st actual attempt at it and not sure what to do,
Sub Add_New_Section_PCR()
'
' Add_New_Section_PCR Macro
' Add a new section to Project Cost in PCT
'
'
Range("C10").End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveCell.EntireRow.Select
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Range(ActiveCell, ActiveCell.Offset(7, 0)).EntireRow.Select
If Selection = Group Then
Selection.Rows.Ungroup
End If
Range(ActiveCell.Offset(2, 0), ActiveCell.Offset(7, 0)).Rows.Group
Sheets("List Options").Select
Range("M18:AC24").Select
Selection.Copy
Sheets("Cost to Complete").Select
Range("C10").End(xlDown).Select
ActiveCell.Offset(2, 0).Select
ActiveSheet.Paste
ActiveCell.EntireRow.RowHeight = 18
ActiveCell.Offset(-1, 0).Select
Range(ActiveCell, ActiveCell.Offset(0, 5)).Interior.ColorIndex = 0
ActiveCell.EntireRow.RowHeight = 9
ActiveCell.FormulaR1C1 = "."
I have attached my code to have a look the area in orange is where i have the problem?
Thanks in advance
I was wondering if VBA can workout if a selection is part of a group and if it is can it then ungroup the selection?
I have added my code below,
basically we have a spreadsheet where i need to add various items differing for every project how many items will be needed to add in so have a very basic code to add a new blank item into. I am very new VBA coding... this is basically my 1st actual attempt at it and not sure what to do,
Sub Add_New_Section_PCR()
'
' Add_New_Section_PCR Macro
' Add a new section to Project Cost in PCT
'
'
Range("C10").End(xlDown).Select
ActiveCell.Offset(1, 0).Select
ActiveCell.EntireRow.Select
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Selection.Insert Shift:=xlDown
Range(ActiveCell, ActiveCell.Offset(7, 0)).EntireRow.Select
If Selection = Group Then
Selection.Rows.Ungroup
End If
Range(ActiveCell.Offset(2, 0), ActiveCell.Offset(7, 0)).Rows.Group
Sheets("List Options").Select
Range("M18:AC24").Select
Selection.Copy
Sheets("Cost to Complete").Select
Range("C10").End(xlDown).Select
ActiveCell.Offset(2, 0).Select
ActiveSheet.Paste
ActiveCell.EntireRow.RowHeight = 18
ActiveCell.Offset(-1, 0).Select
Range(ActiveCell, ActiveCell.Offset(0, 5)).Interior.ColorIndex = 0
ActiveCell.EntireRow.RowHeight = 9
ActiveCell.FormulaR1C1 = "."
I have attached my code to have a look the area in orange is where i have the problem?
Thanks in advance