Trying to add small bit of code to workbook open event

Ironman

Well-known Member
Joined
Jan 31, 2004
Messages
1,069
Office Version
  1. 365
Platform
  1. Windows
Hi

I keep getting "Compile Error: End If without Block If" when I try to add the commented code to the existing code below it
VBA Code:
If Date = DateSerial(Year(Now), 1, 1) Then
'MsgBox "Training Log code: Uncomment (reactivate) Important Messages " & vbNewLine _
'& "For Training Log F9 (Iron Man Runs This Year vs Last Year)", vbInformation, "New Year Update"
'Else
'End If
Dim DummyRow As Long
 With Sheets("Walking")
    DummyRow = .Range("A" & Rows.Count).End(xlUp).Row + 1
    If .Range("A" & DummyRow - 1).Value = Date Then Exit Sub
    .Range("A" & DummyRow).Value = Date
    .Range("B" & DummyRow).Value = "DUMMY ENTRY TO AVOID #REF! ERROR IN THIS SHEET AND TRAINING LOG J9 - OVERTYPE THIS ROW!"
     Range("B" & DummyRow).HorizontalAlignment = xlLeft
    .Range("B" & DummyRow).WrapText = True
    .Range("A" & DummyRow & ":D" & DummyRow).Interior.Color = RGB(255, 255, 0)
    .Range("A" & DummyRow).HorizontalAlignment = xlCenter
    .Range("A" & DummyRow & ":D" & DummyRow).VerticalAlignment = xlCenter
    .Range("A" & DummyRow & ":D" & DummyRow).Font.Name = "Comic Sans MS"
    .Range("A" & DummyRow & ":D" & DummyRow).Font.Bold = True
    .Range("A" & DummyRow & ":D" & DummyRow).Borders.LineStyle = xlContinuous
    .Range("A" & DummyRow & ":D" & DummyRow).Font.Size = 9
    .Range("C" & DummyRow).Value = "1:00"
    .Range("C" & DummyRow).NumberFormat = "[h]:mm"
    .Range("C" & DummyRow).HorizontalAlignment = xlCenter
    .Range("D" & DummyRow).Value = "1.0"
    .Range("D" & DummyRow).NumberFormat = "0.0"
    .Range("D" & DummyRow).HorizontalAlignment = xlCenter

End With
End If

Help would be much appreciated.

Thank you!
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Not at the PC at the moment, but take this bit out then try it
VBA Code:
'Else
'End If
 
Upvote 0
Solution
Brilliant, you fixed it! Thanks a lot once again Michael!
 
Upvote 0

Forum statistics

Threads
1,215,022
Messages
6,122,721
Members
449,093
Latest member
Mnur

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