Results 1 to 6 of 6

VBA Macro for Removing #N/As

Threaded View

  1. #1
    Registered User
    Join Date
    09-22-2020
    Location
    France
    MS-Off Ver
    365
    Posts
    2

    VBA Macro for Removing #N/As

    Hi all,

    I just registered to the forum so nice to meet you all. Before we start, a little bit of my background so you can know who you're helping. I'm a 24yo french finance master's degree student. I'm currently doing my master's thesis whose subject is mutual funds' performance and fees. I basically want to know if an investor who pays more fees will receive more performance, as fund managers claim fees such as management fees are the reflect of their skills.
    So to be able to show whether fees and performance are positively correlated or not, I downloaded a massive database with 10k funds and their monthly NAV (or price) starting from January 2004 (so roughly 200 observations/fund). Now of course, I have lots of #N/A in my database and for 2 reasons :
    - market was closed that day
    - or the fund was not alive yet
    I would like to clean that database and get rid off these #N/As. To do so, I want to target each #N/As that are comprised between 2 values and use the average of these 2 values to replace the #N/A.

    I just wrote a VBA code to help me do that quickly but it doesn't work :

    Public Sub RemoveNA()
    
    Dim row_number As Long
    Dim col_number As Long
    Dim line_number As Long
    Dim column_number As Long
    
    column_number = InputBox("How many columns?")
    line_number = InputBox("How many rows?")
    
    For col_number = 1 To column_number
        For row_number = 1 To line_number
        If Cells(row_number, col_number).Value = "#N/A" Then
            Cells(row_number, col_number).Value = 0
        End If
        Next row_number
    Next col_number
    
    End Sub
    Here is a snapshot of what my excel look like :

    LP61500731 LP61501237 LP61500989 LP61501059 LP40209239 LP40209256
    Net Asset Value 31/08/2020 51.44 30.01 18.30 13.43 11.78 14.13
    Net Asset Value 31/07/2020 52.48 30.65 18.63 13.71 10.94 13.45
    Net Asset Value 30/06/2020 52.77 30.75 18.70 13.64 10.42 12.84
    Net Asset Value 29/05/2020 52.96 30.79 18.74 13.39 10.06 12.65
    Net Asset Value 30/04/2020 51.78 29.99 #N/A 12.95 9.57 12.07
    Net Asset Value 31/03/2020 44.53 25.96 15.74 11.67 8.52 11.13
    Net Asset Value 28/02/2020 52.21 30.00 18.38 13.18 #N/A 12.60
    Net Asset Value 31/01/2020 58.71 33.51 20.60 14.06 12.48 13.68
    Net Asset Value 30/12/2019 61.57 34.98 21.52 15.20 13.07 13.63

    Hope someone understands my problem and can give me any clue about how to solve it

    Have a wonderful day,

    Alexis
    Last edited by davesexcel; 09-22-2020 at 11:02 AM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. removing punctuation macro
    By dorabajji in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-04-2020, 06:18 PM
  2. [SOLVED] removing a macro from routine
    By chubbychub in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2016, 05:44 PM
  3. Removing Input Box from Macro
    By luckyajr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-10-2012, 06:26 PM
  4. Macro for Removing Rows?
    By RecRic in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-21-2007, 08:32 AM
  5. Removing macro
    By news in forum Excel General
    Replies: 2
    Last Post: 05-27-2006, 08:10 AM
  6. Removing a macro
    By Clark in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-25-2006, 09:45 PM
  7. [SOLVED] Removing macro
    By Junkman in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-11-2006, 11:15 AM

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