Bug found on only one PC?

Viewed 44

I am currently trying to change some conditional formatting in an Excel file containing macros and uploaded in Onedrive. However, when I open the file it runs an error message (see picture). I can not detect what the problem is from the VBA tool. My colleague does not have any problems with either the macro or uploading it to Onedrive. Hope someone can help me detect what the issue is?

Excel sheet

Private Sub Workbook_Open()
  Dim WS_Count As Integer
  Dim I, acolumn As Integer
  Dim aRange, acell As Range
  Dim wsName As String
   

  'Set WS_Count equal to the number of worksheets in the active workbook
   WS_Count = ActiveWorkbook.Worksheets.Count

   For I = 1 To WS_Count
     
     wbName = ActiveWorkbook.Worksheets(I).Name
     Worksheets(wbName).Activate
     Set aRange = Range("G9:BF9")
        
     If Range("A1").Value = 1 Then
       acolumn = 7
    
       'Finds the column where to position the line
       For Each acell In aRange
    
         If (acell.Value < Date) Then
             acolumn = acell.Column
         Else
           Exit For
         End If
        Next acell
    '  MsgBox acolumn
        ActiveSheet.Shapes("Line").Left = ActiveSheet.Cells(9, acolumn + 1).Left
      End If
      
    Next I
   wbName = ActiveWorkbook.Worksheets(1).Name
   Worksheets(wbName).Activate

Error message

I tried adding a vertical line that moves with current week (which works), but I'm no longer able to upload the file and if I run the macro it errors.

1 Answers

This doesn't really answer the vba-bit, but you could easily create a vertical line that follows the current week by using conditional formatting using =WEEKNUM(NOW())

conditional formatting

Related