Results 1 to 2 of 2

Running macro from personal.xlsb not working

Threaded View

  1. #1
    Forum Contributor
    Join Date
    04-11-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    245

    Running macro from personal.xlsb not working

    Hi -

    So the other day I received help through the Forum to create a macro. The macro works perfectly when it is stored in the workbook. What I want to do now is store this macro in my Personal.xlsb. So I first copied the macro, I then removed it completely from my active workbook and, three... pasted it in my Personal.xlsb module. However, when I run the macro from my Personal.xlsb I get a 'Variable not defined' error for Sheet1???

    Why is this happening?

    
    Public Sub NormaliseData()
    Dim cel As Range
    Dim intCol As Integer
    Dim i As Long, j As Long
    Dim wksR As Worksheet, wksN As Worksheet
    
        Set wksR = Sheet1
        Set wksN = Sheet2
        i = wksR.Range("C" & Rows.Count).End(xlUp).Row
        For Each cel In wksR.Range("C2:C" & i).Cells
            For intCol = 10 To 16   'cols J->P.
                If wksR.Cells(cel.Row, intCol).Value <> "" Then
                    'session exists - create normalised record:
                    j = wksN.Range("A" & Rows.Count).End(xlUp).Row + 1
                    wksN.Range("A" & j).Value = wksR.Range("C" & cel.Row).Value     'last name.
                    wksN.Range("B" & j).Value = wksR.Range("B" & cel.Row).Value     'first name.
                    wksN.Range("C" & j).Value = wksR.Range("G" & cel.Row).Value     'ph. no.
                    wksN.Range("D" & j).Value = wksR.Range("H" & cel.Row).Value     'email.
                    wksN.Range("E" & j).Value = wksR.Cells(cel.Row, intCol).Value   'session info.
                End If
            Next intCol
        Next cel
        Set cel = Nothing: Set wksR = Nothing: Set wksN = Nothing
        
    End Sub
    Last edited by Grilleman; 05-08-2019 at 10:41 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Personal.XLSB macro pasting into Personal.XLSB
    By davepoth in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-11-2015, 07:40 PM
  2. Running a Personal.XLSB Macro From Within Another Personal.XLSB Macro
    By js0873 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 06-23-2015, 09:58 AM
  3. Replies: 0
    Last Post: 01-15-2015, 05:53 AM
  4. [SOLVED] Personal.Xlsb Workbook.Activate not working
    By Aaron092 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-22-2014, 10:28 AM
  5. PERSONAL.XLSB running before Excel has loaded
    By Aaron092 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-25-2014, 04:00 AM
  6. Replies: 1
    Last Post: 08-07-2013, 09:12 PM
  7. Run-Time Error 1004 When Running Macro from Another Personal Workbook (xlsb)
    By vcs1161 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-01-2013, 12:05 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1