0

I have written the following piece of code. I'm getting the following error "Object variable of With block variable not set". I cannot seem to figure out why.

Dim ResizeRange1 As Long
Dim ResizeRange2 As Long


Dim CurrentWorkSheet As Worksheet
Set CurrenWorkSheet = ActiveWorkbook.Worksheets("RådatatillTable3")

Dim Table1 As ListObject
Dim Table2 As ListObject

Set Table1 = CurrentWorkSheet.ListObjects("Table10")
Set Table2 = CurrentWorkSheet.ListObjects("Table13")

ResizeRange1 = Worksheets("PivotTable3").Cells(2, "D").Value + 1
ResizeRange2 = Worksheets("PivotTable for Tabell2").Cells(2, "H").Value + 1

Table1.Resize CurrentWorkSheet.Range("A1:E" & ResizeRange1)
Table2.Resize CurrentWorkSheet.Range("J1:M" & ResizeRange2)
1
  • 3
    Put Option Explicit at the top of each module. It enforces variable declaration and reports undeclared or misspelled variables/constants at compile time. To have this automatically in new modules, set the Require Variable Declaration option in the VBA Editor. This is really a must have for VBA development. /brokenRecord Commented Aug 1, 2017 at 11:49

1 Answer 1

1

you are missing a t - Set CurrenWorkSheet

Sign up to request clarification or add additional context in comments.

1 Comment

Unbelieve.. spent hours trying to figure it out. Thank you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.