VBA skip to certain section in Macro if cell is blank and issue different msg box

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
888
Office Version
  1. 365
Platform
  1. Windows
Hello I have the below code (I am only providing the bottom half of the code as it is long). What I would like to do is where I left the first gap in the code I want the macro to check if Cell B16 is blank on sheet: "weekly process", if yes I want it to skip to the next blank and run from there but issue a different message box at the end (instread of update complete it would say no results). Can this be done?

Code:
Cells.Select
    lastCol = ActiveSheet.Range("a1").End(xlToRight).Column
    Lastrow = ActiveSheet.Cells(1, 1).End(xlDown).Row
    Selection.AutoFilter
 ActiveSheet.Range("A1", ActiveSheet.Cells(Lastrow, lastCol)).AutoFilter Field:=12, Criteria1:="No"
    Selection.SpecialCells(xlCellTypeVisible).Select
    Selection.ClearContents
    Sheets("Headers").Select
    Rows("1:1").Select
    Selection.Copy
    Sheets("CY").Select
    Range("A1").Select
    ActiveSheet.Paste
    Columns("A:A").Select
    Selection.SpecialCells(xlCellTypeBlanks).Select
    Application.CutCopyMode = False
    Selection.EntireRow.Delete
    Sheets("CY").Select
    Range("A2:H1000000").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Weekly Reprocess").Select
    Range("B16").Select
    ActiveSheet.Paste






****check if B16 is blank, if no continue, if yes skip ahead*******






        Range("A15:I1000000").Select
    ActiveWorkbook.Worksheets("Weekly Reprocess").Sort.SortFields.Add Key:=Range( _
        "B16:B1000000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortNormal
    With ActiveWorkbook.Worksheets("Weekly Reprocess").Sort
        .SetRange Range("A15:I1000000")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
   
    Range("A16").Select
    Application.CutCopyMode = False
    
ActiveCell.FormulaR1C1 = "1"
If Cells(Rows.Count, "B").End(xlUp).Row > 16 Then
    Range("A16").AutoFill Destination:=Range("A16:A" & Cells(Rows.Count, "B").End(xlUp).Row), Type:=xlFillSeries
End If
    Range("A16").Select
Range("A16", Range("A16").End(xlDown).End(xlToRight)).Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    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
    With Selection.Font
        .Name = "Calibri"
        .Size = 11
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .ThemeColor = xlThemeColorLight1
        .TintAndShade = 0
        .ThemeFont = xlThemeFontMinor
    End With
    With Selection.Font
        .Name = "Calibri"
        .Size = 11
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .ThemeColor = xlThemeColorLight1
        .TintAndShade = 0
        .ThemeFont = xlThemeFontMinor
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlGeneral
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
   


******Cell B16 was blank, continue from here*******




Range("A15").Select
    Application.DisplayAlerts = False
Sheets("Report").Select
 ActiveWindow.SelectedSheets.Delete
Sheets.Add().Name = "Report"
Application.DisplayAlerts = True
    
Sheets("Report").Sort.SortFields.Clear
Sheets("CY").Sort.SortFields.Clear
Sheets("DATA").Sort.SortFields.Clear
Sheets("Weekly Reprocess").Sort.SortFields.Clear
Sheets("wk 53").Sort.SortFields.Clear
Sheets("Headers").Sort.SortFields.Clear


Sheets("Headers").Visible = False
Sheets("CY").Visible = False
Sheets("Report").Visible = False
Sheets("DATA").Visible = False
        
        Sheets("Weekly Reprocess").Select
        
        Range("A1").Select




MsgBox "Update Complete"      *********Different message box "No Results"************


End Sub

Thank you for all of your help

Carla
 
Last edited by a moderator:
Try
Code:
Cells.Select
    lastcol = ActiveSheet.Range("a1").End(xlToRight).Column
    LastRow = ActiveSheet.Cells(1, 1).End(xlDown).Row
    Selection.AutoFilter
 ActiveSheet.Range("A1", ActiveSheet.Cells(LastRow, lastcol)).AutoFilter Field:=12, Criteria1:="No"
    Selection.SpecialCells(xlCellTypeVisible).Select
    Selection.ClearContents
    Sheets("Headers").Select
    Rows("1:1").Select
    Selection.Copy
    Sheets("CY").Select
    Range("A1").Select
    ActiveSheet.Paste
    Columns("A:A").Select
    Selection.SpecialCells(xlCellTypeBlanks).Select
    Application.CutCopyMode = False
    Selection.EntireRow.Delete
    Sheets("CY").Select
    Range("A2:H1000000").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Weekly Reprocess").Select
    Range("B16").Select
    ActiveSheet.Paste






If Range("B16") <> "" Then
   Msg = "Update Complete"







        Range("A15:I1000000").Select
    ActiveWorkbook.Worksheets("Weekly Reprocess").Sort.SortFields.Add Key:=Range( _
        "B16:B1000000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortNormal
    With ActiveWorkbook.Worksheets("Weekly Reprocess").Sort
        .SetRange Range("A15:I1000000")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
   
    Range("A16").Select
    Application.CutCopyMode = False
    
ActiveCell.FormulaR1C1 = "1"
If Cells(Rows.Count, "B").End(xlUp).Row > 16 Then
    Range("A16").AutoFill Destination:=Range("A16:A" & Cells(Rows.Count, "B").End(xlUp).Row), Type:=xlFillSeries
End If
    Range("A16").Select
Range("A16", Range("A16").End(xlDown).End(xlToRight)).Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    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
    With Selection.Font
        .Name = "Calibri"
        .Size = 11
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .ThemeColor = xlThemeColorLight1
        .TintAndShade = 0
        .ThemeFont = xlThemeFontMinor
    End With
    With Selection.Font
        .Name = "Calibri"
        .Size = 11
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .ThemeColor = xlThemeColorLight1
        .TintAndShade = 0
        .ThemeFont = xlThemeFontMinor
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlGeneral
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
   


End If

   
   Range("A15").Select
       Application.DisplayAlerts = False
   Sheets("Report").Select
    ActiveWindow.SelectedSheets.Delete
   Sheets.Add().Name = "Report"
   Application.DisplayAlerts = True
       
   Sheets("Report").Sort.SortFields.Clear
   Sheets("CY").Sort.SortFields.Clear
   Sheets("DATA").Sort.SortFields.Clear
   Sheets("Weekly Reprocess").Sort.SortFields.Clear
   Sheets("wk 53").Sort.SortFields.Clear
   Sheets("Headers").Sort.SortFields.Clear
   
   
   Sheets("Headers").Visible = False
   Sheets("CY").Visible = False
   Sheets("Report").Visible = False
   Sheets("DATA").Visible = False
           
           Sheets("Weekly Reprocess").Select
           
           Range("A1").Select
   



If Msg = "" Then Msg = "No result"
MsgBox Msg

End Sub
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Ok I think I understand what you did, you did it backwards from what I was thinking.
If the cell is not blank run the end of the code in its entirety with the message "update complete". If the cell is blank however run from End if with the message "No result". Am I understanding the logic correctly?
 
Upvote 0
Yup, that's what you asked for isn't it?
 
Upvote 0
Yes that works perfectly but I am trying to understand it because I am trying to do the same thing with another spreadsheet of mine but it does not seem to be working. It runs the code in its entirety anyway, it doesnt skip to the End If....
It is the same condition/same situation but I must be missing something....

Code:
If Range("B13") <> "" Then   Msg = "Update Complete"


    
    
    
    Rows("13:13").Select
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlUp
    Range("A13").Select
    Application.CutCopyMode = False
    
    ActiveCell.FormulaR1C1 = "1"
If Cells(Rows.Count, "B").End(xlUp).Row > 13 Then
    Range("A13").AutoFill Destination:=Range("A13:A" & Cells(Rows.Count, "B").End(xlUp).Row), Type:=xlFillSeries
End If
    Range("A13").Select
    Sheets("MW Data").Select
    Cells.Select
    Selection.AutoFilter
    Selection.Delete Shift:=xlUp
    Range("A1").Select
  Sheets("MW Data").Visible = False
    Sheets("Monthly Warranties").Select
    Columns("A:A").Select
    With Selection
        .HorizontalAlignment = xlCenter
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
    End With
LastRowColumnA = Cells(Rows.Count, 1).End(xlUp).Row
Range("A13:H" & LastRowColumnA).Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlHairline
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlHairline
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlHairline
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlHairline
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlHairline
    End With
    With Selection.Borders(xlInsideHorizontal)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlHairline
        End With
    Columns("H:H").ColumnWidth = 31.57
    Range("H13:H300").Select
    With Selection
        .HorizontalAlignment = xlGeneral
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Rows("13:300").Select
    Rows("13:300").EntireRow.AutoFit
    Columns("D:D").EntireColumn.AutoFit
    Columns("C:C").EntireColumn.AutoFit
    Columns("B:B").EntireColumn.AutoFit
    Columns("A:A").EntireColumn.AutoFit
    Columns("E:E").EntireColumn.AutoFit
    
    End If
    
    Worksheets("Report").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, Password:="SADIE"
Worksheets("Monthly Warranties").Protect Password:="SADIE"




    Range("A13").Select
    If Msg = "" Then Msg = "No Results"
MsgBox Msg




'
End Sub

It should have jumped to protecting the sheet and the msg no results as B13 was blank but it ran all the code above anyway....
 
Last edited:
Upvote 0
This doesnt work.... I am going to look at this differently and I just need help with one part.
Macro will run normally until it hits this condition:

How would I structure this?

I do not know if I am using your code tags properly. I am very new to using message boards. I usually stick to mostly excel/office programs so communicating via message board is a new experience. Thank you for your patience.

Try this

Code:
Sub TEST2()
    Cells.Select
    LastCol = ActiveSheet.Range("a1").End(xlToRight).Column
    LastRow = ActiveSheet.Cells(1, 1).End(xlDown).Row
    Selection.AutoFilter
    ActiveSheet.Range("A1", ActiveSheet.Cells(LastRow, LastCol)).AutoFilter Field:=12, Criteria1:="No"
    Selection.SpecialCells(xlCellTypeVisible).Select
    Selection.ClearContents
    Sheets("Headers").Select
    Rows("1:1").Select
    Selection.Copy
    Sheets("CY").Select
    Range("A1").Select
    ActiveSheet.Paste
    Columns("A:A").Select
    Selection.SpecialCells(xlCellTypeBlanks).Select
    Application.CutCopyMode = False
    Selection.EntireRow.Delete
    Sheets("CY").Select
    Range("A2:H1000000").Select
    Application.CutCopyMode = False
    Selection.Copy
    Sheets("Weekly Reprocess").Select
    Range("B16").Select
    ActiveSheet.Paste


'****check if B16 is blank, if no continue, if yes skip ahead*******
[COLOR=#ff0000][B]  If Range("B16").Value [/B][/COLOR][COLOR=#0000ff][B][SIZE=5]<> [/SIZE][/B][/COLOR][COLOR=#ff0000][B]"" Then[/B][/COLOR]
[COLOR=#0000ff]  'If it's not what you want, then change <> to =[/COLOR]
  
    Range("A15:I1000000").Select
    ActiveWorkbook.Worksheets("Weekly Reprocess").Sort.SortFields.Add Key:=Range( _
        "B16:B1000000"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
        xlSortNormal
    With ActiveWorkbook.Worksheets("Weekly Reprocess").Sort
        .SetRange Range("A15:I1000000")
        .Header = xlYes
        .MatchCase = False
        .Orientation = xlTopToBottom
        .SortMethod = xlPinYin
        .Apply
    End With
   
    Range("A16").Select
    Application.CutCopyMode = False
    
    ActiveCell.FormulaR1C1 = "1"
    If Cells(Rows.Count, "B").End(xlUp).Row > 16 Then
        Range("A16").AutoFill Destination:=Range("A16:A" & Cells(Rows.Count, "B").End(xlUp).Row), Type:=xlFillSeries
    End If
        Range("A16").Select
    Range("A16", Range("A16").End(xlDown).End(xlToRight)).Select
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    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
    With Selection.Font
        .Name = "Calibri"
        .Size = 11
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .ThemeColor = xlThemeColorLight1
        .TintAndShade = 0
        .ThemeFont = xlThemeFontMinor
    End With
    With Selection.Font
        .Name = "Calibri"
        .Size = 11
        .Strikethrough = False
        .Superscript = False
        .Subscript = False
        .OutlineFont = False
        .Shadow = False
        .ThemeColor = xlThemeColorLight1
        .TintAndShade = 0
        .ThemeFont = xlThemeFontMinor
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlGeneral
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
[SIZE=3][B][COLOR=#ff0000]    MsgBox "Update Complete"[/COLOR][/B][/SIZE]
[SIZE=3]   [/SIZE]
[SIZE=3][B][COLOR=#ff0000]    Exit Sub[/COLOR][/B][/SIZE]
[SIZE=3][B][COLOR=#ff0000]  End If[/COLOR][/B][/SIZE]




  Range("A15").Select
  Application.DisplayAlerts = False
  Sheets("Report").Select
  ActiveWindow.SelectedSheets.Delete
  Sheets.Add().Name = "Report"
  Application.DisplayAlerts = True
      
  Sheets("Report").Sort.SortFields.Clear
  Sheets("CY").Sort.SortFields.Clear
  Sheets("DATA").Sort.SortFields.Clear
  Sheets("Weekly Reprocess").Sort.SortFields.Clear
  Sheets("wk 53").Sort.SortFields.Clear
  Sheets("Headers").Sort.SortFields.Clear
  
  Sheets("Headers").Visible = False
  Sheets("CY").Visible = False
  Sheets("Report").Visible = False
  Sheets("DATA").Visible = False
          
  Sheets("Weekly Reprocess").Select
  
  Range("A1").Select
  
[SIZE=3][B][COLOR=#ff0000]  MsgBox "No Results"[/COLOR][/B][/SIZE]


End Sub
 
Upvote 0
@willow1985
This line
Code:
If Range("B13") <> "" Then   Msg = "Update Complete"
should be on two lines as per the code in post#11
 
Upvote 0
It is on 2 lines but I am still having the same issue...

Code:
If Range("B13") <> "" Then
 Msg = "Update Complete"


    
    
    
    Rows("13:13").Select
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlUp
    Range("A13").Select
    Application.CutCopyMode = False
    
    ActiveCell.FormulaR1C1 = "1"
If Cells(Rows.Count, "B").End(xlUp).Row > 13 Then
    Range("A13").AutoFill Destination:=Range("A13:A" & Cells(Rows.Count, "B").End(xlUp).Row), Type:=xlFillSeries
End If
    Range("A13").Select
    Sheets("MW Data").Select
    Cells.Select
    Selection.AutoFilter
    Selection.Delete Shift:=xlUp
    Range("A1").Select
  Sheets("MW Data").Visible = False
    Sheets("Monthly Warranties").Select
    Columns("A:A").Select
    With Selection
        .HorizontalAlignment = xlCenter
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
    End With
LastRowColumnA = Cells(Rows.Count, 1).End(xlUp).Row
Range("A13:H" & LastRowColumnA).Select
    Selection.Borders(xlDiagonalDown).LineStyle = xlNone
    Selection.Borders(xlDiagonalUp).LineStyle = xlNone
    With Selection.Borders(xlEdgeLeft)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlHairline
    End With
    With Selection.Borders(xlEdgeTop)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlHairline
    End With
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlHairline
    End With
    With Selection.Borders(xlEdgeRight)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlHairline
    End With
    With Selection.Borders(xlInsideVertical)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlHairline
    End With
    With Selection.Borders(xlInsideHorizontal)
        .LineStyle = xlContinuous
        .ColorIndex = 0
        .TintAndShade = 0
        .Weight = xlHairline
        End With
    Columns("H:H").ColumnWidth = 31.57
    Range("H13:H300").Select
    With Selection
        .HorizontalAlignment = xlGeneral
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = False
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    With Selection
        .HorizontalAlignment = xlCenter
        .VerticalAlignment = xlBottom
        .WrapText = True
        .Orientation = 0
        .AddIndent = False
        .IndentLevel = 0
        .ShrinkToFit = False
        .ReadingOrder = xlContext
        .MergeCells = False
    End With
    Rows("13:300").Select
    Rows("13:300").EntireRow.AutoFit
    Columns("D:D").EntireColumn.AutoFit
    Columns("C:C").EntireColumn.AutoFit
    Columns("B:B").EntireColumn.AutoFit
    Columns("A:A").EntireColumn.AutoFit
    Columns("E:E").EntireColumn.AutoFit
    
    End If
    
    Worksheets("Report").Protect DrawingObjects:=True, Contents:=True, Scenarios:=True _
, AllowSorting:=True, AllowFiltering:=True, Password:="SADIE"
Worksheets("Monthly Warranties").Protect Password:="SADIE"




    Range("A13").Select
    If Msg = "" Then Msg = "No Results"
MsgBox Msg




'
End Sub
 
Upvote 0
If it runs the entire code, then B13 on the active sheet isn't empty.
 
Upvote 0
If you want you can upload your file to the cloud, to test with the data you have.

You could upload a copy of your file to a free site such www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. If the workbook contains confidential information, you could replace it with generic data.



And it also helps you clean your code a bit, for example you have these instructions several times:


Code:
[COLOR=#0000ff]    With Selection[/COLOR]
[COLOR=#0000ff]        .HorizontalAlignment = xlGeneral[/COLOR]
[COLOR=#0000ff]        .VerticalAlignment = xlBottom[/COLOR]
[COLOR=#0000ff]        .WrapText = True[/COLOR]
[COLOR=#0000ff]        .Orientation = 0[/COLOR]
[COLOR=#0000ff]        .AddIndent = False[/COLOR]
[COLOR=#0000ff]        .IndentLevel = 0[/COLOR]
[COLOR=#0000ff]        .ShrinkToFit = False[/COLOR]
[COLOR=#0000ff]        .ReadingOrder = xlContext[/COLOR]
[COLOR=#0000ff]        .MergeCells = False[/COLOR]
[COLOR=#0000ff]    End With[/COLOR]
[COLOR=#ff0000]    With Selection[/COLOR]
[COLOR=#ff0000]        .HorizontalAlignment = xlCenter[/COLOR]
[COLOR=#ff0000]        .VerticalAlignment = xlBottom[/COLOR]
[COLOR=#ff0000]        .WrapText = True[/COLOR]
[COLOR=#ff0000]        .Orientation = 0[/COLOR]
[COLOR=#ff0000]        .AddIndent = False[/COLOR]
[COLOR=#ff0000]        .IndentLevel = 0[/COLOR]
[COLOR=#ff0000]        .ShrinkToFit = False[/COLOR]
[COLOR=#ff0000]        .ReadingOrder = xlContext[/COLOR]
[COLOR=#ff0000]        .MergeCells = False[/COLOR]
[COLOR=#ff0000]    End With[/COLOR]
 
Upvote 0
I figured it out! Thank you very much. B13 wasnt completely empty. I moved the starting point of when to look for the empty cell and all is good.

Thanks again!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,255
Members
449,075
Latest member
staticfluids

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