Hi guys,
I get run-time error -2147417848 (80010108)
Automation error
The object invoked has disconnected from its clients.
When I use
I do not get these errors, however, the macro won't work either.
I guess it has something to do with the ActiveSheet I am using?
I get run-time error -2147417848 (80010108)
Automation error
The object invoked has disconnected from its clients.
When I use
Code:
Application.EnableEvents = False
I guess it has something to do with the ActiveSheet I am using?
Code:
Sub FindTotalAmountOfRowsInColumn()
Dim startCol As String
Dim startRow As Long
Dim lastrow As Long
Dim lastCol As Long
Dim myCol As String
Dim ws, ws2 As Worksheet
Dim Rng As Range
Dim cell As Range
Application.ScreenUpdating = False
Set ws2 = ActiveSheet 'Preserves a reference to the active sheet as ws2
ThisWorkbook.Activate 'Makes this workbook the one that is displayed
Set ws = ThisWorkbook.Sheets("Sheet1")
With ws
startCol = "B"
startRow = 13
lastrow = ws.Range(startCol & ws.Rows.count).End(xlUp).Row
'lastCol = ws.Cells(2, ws.Columns.Count).End(xlToLeft).Column
lastCol = ws2.UsedRange.Columns(ws2.UsedRange.Columns.count).Column
myCol = GetColumnLetter(lastCol)
Set Rng = ws.Range(startCol & startRow & ":" & myCol & lastrow)
ws.Range("A8").Value = "ITEMCOUNT:" & Rng.Rows.count
End With
Application.ScreenUpdating = True
End Sub