+ Reply to Thread
Results 1 to 3 of 3

Excel VBA Worksheet Change on Cell input....so close...please help!

Hybrid View

  1. #1
    Registered User
    Join Date
    09-15-2014
    Location
    New York City
    MS-Off Ver
    2013
    Posts
    24

    Excel VBA Worksheet Change on Cell input....so close...please help!

    Hi (Months at this yet still a newbee)
    So this 'Private Sub Worksheet_Change(ByVal Target As Range)' is making my brain melt! (There are two events on a sheet which I've combined). Individually they both execute fine when the other is removed. Not so much together. One should save the active workbook with two separate cell input names while the other moves data into another sheet when it meets the condition. Here's the code with hashtags and my sincere thanks.

    'Private Sub Worksheet_Change(ByVal Target As Range)
    'Application.ScreenUpdating = False

    'If Intersect(Target, Range("E1", "E8")) Is Nothing Then Exit Sub
    'Dim FPATH As String
    'FPATH = "C:\Users\Accounting\XXXXXX\Excel Schedules\"
    'ActiveWorkbook.SaveAs FPATH & Range("E1").Value & " " & Range("E8").Value2 & ".xlsm"
    'Application.ScreenUpdating = True
    'Application.ScreenUpdating = False
    'If Intersect(Target, Range("A:A")) Is Nothing Then Exit Sub
    'If Intersect(Target, Range("A:A")) = "No to Material" Then
    'Target.EntireRow.Copy Sheets("Non Avail").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
    'Target.EntireRow.Cells.SpecialCells(xlConstants, xlTextValues).ClearContents

    'End If

    'Application.ScreenUpdating = True

    'End Sub

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Excel VBA Worksheet Change on Cell input....so close...please help!

    Ok. This is simple,

    Look at your two equations that cause your macro to stop working.


    Private Sub Worksheet_Change(ByVal Target As Range)
    Application.ScreenUpdating = False
    
    '*****************************************************************
    'If your target cell is not in this range then the macro will not even see your second piece of code
    'If Intersect(Target, Range("E1", "E8")) Is Nothing Then Exit Sub
    'Replace with:
    If Intersect(Target, Range("E1", "E8")) Is Nothing Then goto 100
    '*****************************************************************
    
    Dim FPATH As String
    FPATH = "C:\Users\Accounting\XXXXXX\Excel Schedules\"
    ActiveWorkbook.SaveAs FPATH & Range("E1").Value & " " & Range("E8").Value2 & ".xlsm"
    goto 200
    
    100  If Intersect(Target, Range("A:A")) Is Nothing Then goto 200
    Target.value <> "No to Material" Then goto 200
    Target.EntireRow.Copy Sheets("Non Avail").Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
    Target.EntireRow.Cells.SpecialCells(xlConstants, xlTextValues).ClearContents
    
    200 Application.ScreenUpdating = True
    
    'End Sub

  3. #3
    Registered User
    Join Date
    09-15-2014
    Location
    New York City
    MS-Off Ver
    2013
    Posts
    24

    Re: Excel VBA Worksheet Change on Cell input....so close...please help!

    Wow mehmetcik
    It only looks simple...especially to a valued contributor not to a newbee who has been "Frankensteining" code! This has been the most helpful response I received on any forum. Please accept my sincere thanks. I'm almost finished...its taken 6 months.

+ 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. Replies: 4
    Last Post: 07-24-2015, 08:33 AM
  2. Replies: 2
    Last Post: 04-10-2014, 07:06 AM
  3. Replies: 0
    Last Post: 08-31-2012, 01:58 PM
  4. Replies: 2
    Last Post: 06-11-2012, 07:30 PM
  5. Error trying to close down dbase IV file used for input to excel
    By don in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-03-2006, 09:40 PM

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