+ Reply to Thread
Results 1 to 5 of 5

formula not working after macro runs

  1. #1
    Registered User
    Join Date
    08-24-2022
    Location
    U.S.
    MS-Off Ver
    365
    Posts
    3

    formula not working after macro runs

    My workbook contains 7 dropdown lists and a formula to return values upon criteria selection. The formula was working well until I added a macro to reset all cells to blank. Now, however, it only returns "none" rather than selecting the actual return value. I also added a macro to make multiple selections on the first dropdown list, but the formula failed after the clear macro was added.

    code to reset dropdowns
    [Public Sub resetDVs()
    [b5:h5,b8] = " "
    End Sub]

    code to allow multiple choices
    [Private Sub Worksheet_Change(ByVal Target As Range)
    Dim Oldvalue As String
    Dim Newvalue As String
    Application.EnableEvents = True
    On Error GoTo Exitsub
    If Not Intersect(Target, Range("b5")) Is Nothing Then
    If Target.SpecialCells(xlCellTypeAllValidation) Is Nothing Then
    GoTo Exitsub
    Else: If Target.Value = "" Then GoTo Exitsub Else
    Application.EnableEvents = False
    Newvalue = Target.Value
    Application.Undo
    Oldvalue = Target.Value
    If Oldvalue = "" Then
    Target.Value = Newvalue
    Else
    If InStr(1, Oldvalue, Newvalue) = 0 Then
    Target.Value = Oldvalue & vbNewLine & Newvalue
    Else:
    Target.Value = Oldvalue
    End If
    End If
    End If
    End If
    Application.EnableEvents = True
    Exitsub:
    Application.EnableEvents = True
    End Sub]
    Attached Files Attached Files
    Last edited by lwagner87; 08-24-2022 at 09:47 AM.

  2. #2
    Valued Forum Contributor PeteABC123's Avatar
    Join Date
    09-21-2012
    Location
    Chicago, IL
    MS-Off Ver
    MS Office 365 ver 2202
    Posts
    1,104

    Re: formula not working after macro runs

    Hi lwagner87: welcome to the forum

    You'll probably need to share the section of code that resets the cells to blank here.

    Pete

  3. #3
    Registered User
    Join Date
    08-24-2022
    Location
    U.S.
    MS-Off Ver
    365
    Posts
    3

    Re: formula not working after macro runs

    done. file attached as well

  4. #4
    Forum Contributor
    Join Date
    01-08-2017
    Location
    Salt Lake City, Ut.
    MS-Off Ver
    2019 and 365
    Posts
    135

    Re: formula not working after macro runs

    I suggest you read the Form Rules for post that include code. Click on the Forum Rules menu at the top. Specifically: 2. Programming code must be enclosed in code tags to improve readability.

  5. #5
    Registered User
    Join Date
    08-24-2022
    Location
    U.S.
    MS-Off Ver
    365
    Posts
    3

    Re: formula not working after macro runs

    I've done so and attached a draft copy for review. Thank you for your assistance!

+ 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. VBA which runs macros when cell clicked - 82% working
    By Kcroft9 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 04-08-2022, 03:31 PM
  2. [SOLVED] Skip Cells Which Has Formula When Macro Runs
    By Barieq in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-11-2022, 06:33 AM
  3. [SOLVED] Macro runs quick initially then bogs down after a few runs
    By pongmeister in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-19-2017, 02:02 PM
  4. [SOLVED] help index and match macro not working but formula working??
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-28-2016, 06:37 AM
  5. How to enter a formula into a cell after a macro runs
    By Zimmerman in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-11-2015, 02:14 PM
  6. Macro that runs for every sheet stops working
    By cooket4 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-08-2014, 09:58 AM
  7. Windows XP : Window XP runs slow and not working properly
    By sarinky in forum Microsoft Windows Help
    Replies: 3
    Last Post: 03-27-2012, 02:16 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