• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member
  • Login

Invalid Forward Reference|VBA & Macros|Excel Forum|My Online Training Hub

You are here: Home / Invalid Forward Reference|VBA & Macros|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumVBA & MacrosInvalid Forward Reference
sp_PrintTopic sp_TopicIcon
Invalid Forward Reference
Avatar
Preston Haralson

New Member
Members
Level 0
Forum Posts: 1
Member Since:
April 12, 2022
sp_UserOfflineSmall Offline
1
April 12, 2022 - 8:43 am
sp_Permalink sp_Print

I have a code that I use to "clean up" a workbook that I use for work. I've been using it for years and all of a sudden I got a Run Time Error. I'm not sure if it's something that I did or a software update. Any help would be appreciated as I'm not very proficient at vba code. The error is highlighted in red below, according to excel.

 

The error is as follows:

Run-time error '-2147319767 (80028029)

Automation error

Invalid forward reference, or reference to uncompiled type.

 

Code being used:

CleanUp Macro

Dim answer As Integer

answer = MsgBox("WARNING!" & vbLf & "This will clear all data." & vbLf & "Continue?", _

vbExclamation + vbYesNo, _

"WARNING - This will clear data")

If answer = vbNo Then Exit Sub

Sheet3.Select

Range("B1").Select

Application.CutCopyMode = False

Selection.Copy

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _

:=False, Transpose:=False

ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True

Range("B5").Select

Sheet1.Select

Cells.Select

Application.CutCopyMode = False

Selection.Copy

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _

:=False, Transpose:=False

Rows("31:31").Select

Range(Selection, Selection.End(xlDown)).Select

Application.CutCopyMode = False

Selection.Delete Shift:=xlUp

Range("B5").Select

Sheet6.Select

ActiveWindow.SelectedSheets.Delete

Sheet1.Activate

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 689
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
2
April 12, 2022 - 10:52 pm
sp_Permalink sp_Print

Generally when I've seen this nonsensical error, the solution involves doing something to force a recompile of the VBA project. For example, add a new reference (using Tools-References in the VB Editor), then save, close and re-open the workbook. If that fixes it, you can usually remove the reference you added and save again.

Avatar
Kathy Christensen

New Member
Members

Power BI
Level 0
Forum Posts: 1
Member Since:
May 9, 2014
sp_UserOfflineSmall Offline
3
June 23, 2022 - 9:16 am
sp_Permalink sp_Print

@Velouria: Thanks so much! I had a similar error and your solution worked.  I had spent two full days trying to trouble-shoot.

Avatar
Velouria
London or thereabouts
Moderator
Members


Trusted Members

Moderators
Level 4
Forum Posts: 689
Member Since:
November 1, 2018
sp_UserOfflineSmall Offline
4
June 23, 2022 - 6:06 pm
sp_Permalink sp_Print

Hi Kathy,

 

Glad it was useful to you. 🙂

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Evan Sim, Kumud Patel
Guest(s) 7
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 880
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 237
Jessica Stewart: 219
A.Maurizio: 213
Aye Mu: 201
Hans Hallebeek: 184
Newest Members:
Hilary Burchfield
Richie Wright
Adel Kock
Barbara Murray
Doug Milne
https://www.afabola.net/
Siobhan Stringer
Rob Rooth
Tom Lewis
Jennifer Rodriguez-Avila
Forum Stats:
Groups: 3
Forums: 24
Topics: 6540
Posts: 28628

 

Member Stats:
Guest Posters: 49
Members: 32829
Moderators: 2
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel Office Scripts
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook

Sign up to our newsletter and join over 400,000
others who learn Excel and Power BI with us.

 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate
  • Sponsor Our Newsletter

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.