Hello,
I'm trying to insert a number of column in the middle of worksheet. The number of columns are dynamic based on the date range in another tab. I need to take the total number of columns in that tab and dynamically change the number of columns i add in based on whether a toggle choice is "month", "quarter", or "year". I am getting stuck on "InsertColumn" both in the location i want and the correct number of columns that need to be entered. This is my code so far:
'This macro is used to add the correct number of columns to the Financial Evaluation tab so that the equity costs
'are captured prior to COD and computed in the overall IRR
'
Dim NumberOfColumns As Double
Dim Cols_to_Insert As Double
Dim Period As Double
NumberOfColumns = WorksheetFunction.CountIf(Sheets("Construction").Range("H6:BY6"), ">0")
Period = Worksheets("Financial Evaluation").Range("Fin_mon_length")
Cols_to_Insert = WorksheetFunction.RoundUp(NumberOfColumns / Period, 0)
Range("G1").Offset(0, 1).EntireColumn.Cells(1, Cols_to_Insert).Insert
Worksheets("Financial Evaluation").Range("C95") = "=XIRR(OFFSET(range("G94"),0,1,1,COUNTIF(range("H10:IZ10"),">0")),OFFSET(range("G10"),0,1,1,COUNTIF(range("H10:IZ10"),">0")))"
Msg = Cols_to_Insert
MsgBox Msg
End Sub
I'm trying to insert a number of column in the middle of worksheet. The number of columns are dynamic based on the date range in another tab. I need to take the total number of columns in that tab and dynamically change the number of columns i add in based on whether a toggle choice is "month", "quarter", or "year". I am getting stuck on "InsertColumn" both in the location i want and the correct number of columns that need to be entered. This is my code so far:
'This macro is used to add the correct number of columns to the Financial Evaluation tab so that the equity costs
'are captured prior to COD and computed in the overall IRR
'
Dim NumberOfColumns As Double
Dim Cols_to_Insert As Double
Dim Period As Double
NumberOfColumns = WorksheetFunction.CountIf(Sheets("Construction").Range("H6:BY6"), ">0")
Period = Worksheets("Financial Evaluation").Range("Fin_mon_length")
Cols_to_Insert = WorksheetFunction.RoundUp(NumberOfColumns / Period, 0)
Range("G1").Offset(0, 1).EntireColumn.Cells(1, Cols_to_Insert).Insert
Worksheets("Financial Evaluation").Range("C95") = "=XIRR(OFFSET(range("G94"),0,1,1,COUNTIF(range("H10:IZ10"),">0")),OFFSET(range("G10"),0,1,1,COUNTIF(range("H10:IZ10"),">0")))"
Msg = Cols_to_Insert
MsgBox Msg
End Sub