+ Reply to Thread
Results 1 to 27 of 27

Excel 2013 keep crashing when i run macro

Hybrid View

  1. #1
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Excel 2013 keep crashing when i run macro

    you are using FormulaR1C1 method
    i assume because you just recorded marco and used whatever it gave you and tried to amend it
    thats ok....its how i learnt also

    R = Row
    C = Column
    R(0)C(-3) = 0 rows, 3 columns back..relative to your range

    take this line of code
    and assuming rownum is 30

    Range("P" & RowNum).FormulaR1C1 = "= VLOOKUP(RC[-3],[MISSINGUSERNAMEDEPT.xlsx]Sheet1!C1:C5,2,0)"
    range would (P30)
    RC[-3] = p30 + zero rows + (- 3 columns) = M30
    explained from above C1:C5 = A:E

    the formula now reads
    vlookup(m30,[Workbook]Worksheet!A:E,2,0)

    more reading about it can be found here
    https://excelmate.wordpress.com/2013...e-style-vs-a1/

    alternatively don't use R1C1 just use .formula instead

    Range("P" & rownum).Formula = "= VLOOKUP(" & Range("M" & rownum).Address & ",[MISSINGUSERNAMEDEPT.xlsx]Sheet1!A:E,2,0)"
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Excel 2013 keep crashing when i run macro

    if you want it part of the code
        For rownum = 1 To MaxRowNum
        
            If UCase(Cells(rownum, 16)) Like "*NOT INDICATED*" Or UCase(Cells(rownum, 17)) Like "*NOT INDICATED*" Then
            
                'Vlookup User Name from the file MISSINGUSERNAMEDEPT.xlsx
                Range("P" & rownum).FormulaR1C1 = "= VLOOKUP(RC[-3],[MISSINGUSERNAMEDEPT.xlsx]Sheet1!C1:C5,2,0)"
                
                'Vlookup Dept from the file MISSINGUSERNAMEDEPT.xlsx
                
                Range("Q" & rownum).FormulaR1C1 = "= VLOOKUP(RC[-4],[MISSINGUSERNAMEDEPT.xlsx]Sheet1!C1:C5,3,0)"
            
                Range(Cells(rownum, "P"), Cells(rownum, "Q")).Select
                Selection.Copy
                Selection.PasteSpecial Paste:=xlPasteValues
            
            End If
            
            If UCase(Cells(rownum, 16).Value) = "#N/A" Then
                Cells(rownum, 16).Value = "NOT INDICATED"
            End If
            
            If UCase(Cells(rownum, 17).Value) = "#N/A" Then
                Cells(rownum, 17).Value = "NOT INDICATED"
            End If
            
        Next
    add two more IF blocks

  3. #3
    Registered User
    Join Date
    07-01-2015
    Location
    Singapore
    MS-Off Ver
    2013
    Posts
    66

    Re: Excel 2013 keep crashing when i run macro

    Quote Originally Posted by humdingaling View Post
    if you want it part of the code
        For rownum = 1 To MaxRowNum
        
            If UCase(Cells(rownum, 16)) Like "*NOT INDICATED*" Or UCase(Cells(rownum, 17)) Like "*NOT INDICATED*" Then
            
                'Vlookup User Name from the file MISSINGUSERNAMEDEPT.xlsx
                Range("P" & rownum).FormulaR1C1 = "= VLOOKUP(RC[-3],[MISSINGUSERNAMEDEPT.xlsx]Sheet1!C1:C5,2,0)"
                
                'Vlookup Dept from the file MISSINGUSERNAMEDEPT.xlsx
                
                Range("Q" & rownum).FormulaR1C1 = "= VLOOKUP(RC[-4],[MISSINGUSERNAMEDEPT.xlsx]Sheet1!C1:C5,3,0)"
            
                Range(Cells(rownum, "P"), Cells(rownum, "Q")).Select
                Selection.Copy
                Selection.PasteSpecial Paste:=xlPasteValues
            
            End If
            
            If UCase(Cells(rownum, 16).Value) = "#N/A" Then
                Cells(rownum, 16).Value = "NOT INDICATED"
            End If
            
            If UCase(Cells(rownum, 17).Value) = "#N/A" Then
                Cells(rownum, 17).Value = "NOT INDICATED"
            End If
            
        Next
    add two more IF blocks
    Normally , i do this manually
    Ctrl+H
    Find "#n/a"
    Replace with "NOT INDICATED"
    and I want to automate the process cos I'm adding more methods after this Method .

    Anyway, Thank you so much . I really really appreciate your help and your quick response. Thank you
    Last edited by fluffyvampirekitten; 07-07-2015 at 02:50 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Custom cell formatting crashing Excel 2013
    By rpdhuk in forum Excel General
    Replies: 1
    Last Post: 06-23-2015, 12:29 PM
  2. VBA code causing memory leak. Crashing Excel 2013/64. Please help.
    By kabammi in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-10-2015, 11:19 PM
  3. Macros crashing Excel 2013
    By Thor42 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-03-2015, 05:13 PM
  4. Excel 2013 Crashing on opening a XLSM file
    By Wongadob in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-05-2014, 05:10 AM
  5. Replies: 3
    Last Post: 07-20-2014, 11:46 AM

Tags for this Thread

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