TenDeadGoats
05-05-2020, 12:13 PM
Hi Guys,
I think this one might be pretty simple but I've been struggling with it a little bit. I just figured out how to insert a column onto the end of my table and populate it with the data I want. I just need to figure out how to autofit it now. I think I'm pretty close. Here is what I have so far.
Sub Table_Insert()
Dim LastColumn As Integer
Dim FitRange As Range
ActiveSheet.ListObjects("Table1").ListColumns.Add
LastColumn = ActiveSheet.ListObjects("Table1").Range.Columns.Count
ActiveSheet.ListObjects("Table1").HeaderRowRange(LastColumn).Select
ActiveCell.FormulaR1C1 = "CLIENT NAME"
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=TRIM(UPPER(SUBSTITUTE(R[0]C[-13],""."","""")))"
ActiveSheet.ListObjects("Table1").ListColumns(LastColumn).Range.Select
Set FitRange = Selection
Worksheets("Commissions Data").Range(FitRange).Columns.AutoFit
End Sub
Thanks for the help!
I think this one might be pretty simple but I've been struggling with it a little bit. I just figured out how to insert a column onto the end of my table and populate it with the data I want. I just need to figure out how to autofit it now. I think I'm pretty close. Here is what I have so far.
Sub Table_Insert()
Dim LastColumn As Integer
Dim FitRange As Range
ActiveSheet.ListObjects("Table1").ListColumns.Add
LastColumn = ActiveSheet.ListObjects("Table1").Range.Columns.Count
ActiveSheet.ListObjects("Table1").HeaderRowRange(LastColumn).Select
ActiveCell.FormulaR1C1 = "CLIENT NAME"
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=TRIM(UPPER(SUBSTITUTE(R[0]C[-13],""."","""")))"
ActiveSheet.ListObjects("Table1").ListColumns(LastColumn).Range.Select
Set FitRange = Selection
Worksheets("Commissions Data").Range(FitRange).Columns.AutoFit
End Sub
Thanks for the help!