Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 1st, 2006, 01:45 PM
Fin Fin is offline
Registered User
 
Join Date: Jan 2006
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Compile Error: Variable not defined

I keep on getting msg 'Compile Error: Variable not defined' when I try to run this code. It seems to be when it reaches 'tbxLoadRef2' yet this object does exist within the active userform. Can anybody help me please!

Private Sub cbnAmend_Click()

' Search Database for valid reference
    Dim LoadRef As Variant

    Windows("SourceWB.xls").Activate
    Sheets("Loadings").Select
    Range("A1").Offset(1, 0).Select
    Range(Selection, Selection.End(xlDown)).Select

    With Selection
    Set LoadRef = .Find(Listbox1.Text, LookIn:=xlValues)

    End With
' Close userform
    Unload Me

' Select found value
    Windows("SourceWB").Activate
    Sheets("Loadings").Select
    LoadRef.Select

' Open userform
    frmAmendLoad.Show
' Populate userform with info from worksheet
    tbxLoadRef2.Text = Selection.Value
    Selection.Offset(0, 4).Select
    tbxSuppRef.Text = Selection.Value
    ActiveCell.Offset(0, -ActiveCell.Column + 2).Select
    tbxDate2.Text = Selection.Value

End Sub






Similar Threads
Thread Thread Starter Forum Replies Last Post
variable not defined error? SKhna ASP.NET 2.0 Basics 1 April 1st, 2008 05:48 AM
Help : compile error : sub or function not defined Specialist VB How-To 2 June 20th, 2007 04:34 AM
Appl-defined or Object-defined error 1004 chp Excel VBA 3 April 4th, 2006 08:12 AM
Compile error-variable not defined tmiller1 VB Databases Basics 1 February 15th, 2005 04:15 PM
Application-defined or object-defined error James Excel VBA 1 August 12th, 2003 11:50 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.