Run-time error'91: Object variable to With block variable not set

jball2018

New Member
Joined
Feb 21, 2018
Messages
3
Hi, I am very elementary when it comes to creating macros and code. I have a macro that was given to me to run on data that I exported from an application with only certain columns. This macro is supposed to format the data as needed for meetings. I am trying to run the macro and getting the run time error 91. Please see my code below and let me know what I should do. Thank you!
Code:
Sub newBacklogFormat()
'
' newBacklogFormat Macro
'
'
    Columns("C:C").Select
    Selection.Cut
    Columns("A:A").Select
    ActiveSheet.Paste
    Columns("C:C").Select
    Selection.Delete Shift:=xlToLeft
    Range("A1").Select
    ActiveCell.FormulaR1C1 = "Priority"
    Range("B1").Select
    ActiveCell.FormulaR1C1 = "CR"
    Range("C1").Select
    ActiveCell.FormulaR1C1 = "Application"
    Range("D1").Select
    ActiveCell.FormulaR1C1 = "Summary"
    Range("E1").Select
    ActiveCell.FormulaR1C1 = "CR Type/Classification"
    Range("F1").Select
    ActiveCell.FormulaR1C1 = "CR Service Area"
    Range("G1").Select
    ActiveCell.FormulaR1C1 = "Status"
    Range("H1").Select
    ActiveCell.FormulaR1C1 = "Complexity"
    Range("K1").Select
    ActiveCell.FormulaR1C1 = "Scheduled End Date"
    Range("H2").Select
    ActiveWindow.ScrollColumn = 1
    Cells.Select
    Cells.EntireColumn.AutoFit
    Columns("D:D").Select
    With Selection
        .HorizontalAlignment = xlGeneral
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Selection.ColumnWidth = 57.44
    Cells.Select
    Cells.EntireRow.AutoFit
    Range("A1:K15").Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    With Selection.Borders(xlInsideHorizontal)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlThin
    End With
    Columns("E:F").Select
    With Selection
        .HorizontalAlignment = xlGeneral
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Selection.ColumnWidth = 20.11
    Columns("G:G").Select
    With Selection
        .HorizontalAlignment = xlGeneral
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Selection.ColumnWidth = 17.78
    Cells.Select
    Cells.EntireColumn.AutoFit
    Range("A2").Select
    ActiveCell.FormulaR1C1 = "TBD"
    Range("A3").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("A4").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("A5").Select
    ActiveCell.FormulaR1C1 = "8"
    Range("A6").Select
    ActiveCell.FormulaR1C1 = "1"
    Range("A7").Select
    ActiveCell.FormulaR1C1 = "7"
    Range("A8").Select
    ActiveCell.FormulaR1C1 = "5"
    Range("A9").Select
    ActiveCell.FormulaR1C1 = "6"
    Range("A10").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("A11").Select
    ActiveCell.FormulaR1C1 = "2"
    Range("A12").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("A13").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("A14").Select
    ActiveCell.FormulaR1C1 = "0"
    Range("A15").Select
    ActiveCell.FormulaR1C1 = "NEW"
    Range("A16").Select
    ActiveCell.FormulaR1C1 = ""
    Columns("A:A").Select
    With Selection
        .HorizontalAlignment = xlLeft
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Range("A1:K15").Select
    Selection.AutoFilter
    Cells.Select
    Cells.EntireColumn.AutoFit
    Range("A1").Select
    ActiveWorkbook.Worksheets("Sheet 1").AutoFilter.Sort.SortFields.Clear
    ActiveWorkbook.Worksheets("Sheet 1").AutoFilter.Sort.SortFields.Add Key:= _
        Range("A1:A15"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortNormal
    With ActiveWorkbook.Worksheets("Sheet 1").AutoFilter.Sort
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
End Sub
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Hello jball2108,

At which line in the code does the error occur?
 
Upvote 0
I'm sorry I don't see where it is pointing to a specific line of code. I tried to send a screen shot and this thread won't allow me to paste.
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,212
Members
452,618
Latest member
Tam84

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top