Hi All.
I am importing some data from an old workbook to a new one. In the new workbook sheet, where the data shall be, I have a commandbottom (only visible this half of the year) with the following code:
Private Sub OldWeeks_Click()
Application.ScreenUpdating = False
Select Case OldWeeks.Caption
Case "Show all weeks"
Columns("D:GJ").Hidden = False
For i = 4 To 192
If Cells(4, i).Value = "" Or (Cells(2, i).Value = "Su" And Worksheets("Medarbejdere").Cells(50, 3).Value = "No") Then Columns(i).Hidden = True
Next i
OldWeeks.Caption = "Hide old weeks"
Case "Hide old weeks"
Dato = DateValue("1/" & 6 * Left(Me.Name, 1) - 5 & "/" & Right(Me.Name, 4))
Dato = Dato - Weekday(Dato)
i = 4
Do Until Dato = Date - Weekday(Date) or i>192
Columns(i).Hidden = True ’’’’’’’’’ Error in this line ’’’’’’’’’’’’’’’’’’’
Dato = Dato + 1
i = i + 1
Loop
OldWeeks.Caption = "Show all weeks"
End Select
Cells(ActiveCell.Row + 1, ActiveCell.Column + 1).Activate
Application.ScreenUpdating = True
End Sub
When I am copying a lot of data I will get a Run-time error ’1004’ in the columns(i).Hidden =True. (the value of i is around 33 and 80)
Why do I get this error???
Help please.
Woody