statement invalid outside type block

kylefoley76

Well-known Member
Joined
Mar 1, 2010
Messages
1,553
I'm getting the error in the title of the thread and VBA highlights the time_lastcell2 as the culprit.

Code:
Dim first_cell As Integer
Dim time2 As Worksheet
Set time2 = ActiveWorkbook.Sheets("time")


Dim lastday As Date, lastday_time As Date
time_lastcell2 As Integer


With time2
time_lastcell2 = .Range("e65000").End(xlUp).Row
End With


lastday_time = time2.Range("e" & time_lastcell).Address




'Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
    Application.EnableEvents = False




With ActiveSheet
first_cell = .Range("c65000").End(xlUp).Row


lastday = .Range("b" & first_cell).Address

[more code]
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
kylefoley76,


Missing Dim....

Dim time_lastcell2 As Integer
 
Upvote 0
Thanks that did it. Also Rick, about the fact that I thought you didn't like one-liners expressing gratitude. I thought I read that on excelfox but I went back to look for it and I couldn't find it.
 
Upvote 0

Forum statistics

Threads
1,221,543
Messages
6,160,421
Members
451,644
Latest member
hglymph

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