Results 1 to 3 of 3

VBA Command Button not working

Threaded View

  1. #1
    Registered User
    Join Date
    06-14-2017
    Location
    Phoenix, Arizona
    MS-Off Ver
    2013
    Posts
    1

    Question VBA Command Button not working

    I created a command button with a VBA code to print invoices for clients. Yesterday, when I clicked the button it worked, but now when I click the button nothing happens. I have tried all the fixes. I have deleted the button and reset it. I have gone into the VBA design mode and tried running the code from there. Nothing happens.



    I can't figure out why. I have updated, ran the fix from Microsoft, deleted the .exd files, and still nothing. Can someone please help? Here is a copy of the code I wrote.



    Private Sub CommandButton1_Click()
    
    Dim clientname As String
    Dim location As String
    Dim address As String
    Dim r As Long
    Dim slrate As String
    Dim clientrate As String
    Dim discount As String
    Dim payments As String
    Dim balancedue As String
    Dim notes As String
    Dim billingdate As String
    Dim duedate As String
    Dim pastdue As String
    Dim path As String
    Dim myfilename As String
    lastrow = Sheets("June 2017 SL Fees").Range("O" & Rows.Count).End(xlUp).Row
    r = 10
    For r = 10 To lastrow
    If Cells(r, 15).Value = "Detox" Then GoTo nextrow
    If Cells(r, 15).Value = "INPT" Then GoTo nextrow
    If Cells(r, 15).Value = "Discharged" Then GoTo nextrow
    If Cells(r, 15).Value = "" Then GoTo nextrow
    
    
    clientname = Sheets("June 2017 SL Fees").Cells(r, 16).Value
    location = Sheets("June 2017 SL Fees").Cells(r, 15).Value
    address = Sheets("June 2017 SL Fees").Cells(r, 23).Value
    slrate = Sheets("June 2017 SL Fees").Cells(r, 24).Value
    clientrate = Sheets("June 2017 SL Fees").Cells(r, 25).Value
    discount = Sheets("June 2017 SL Fees").Cells(r, 26).Value
    payments = Sheets("June 2017 SL Fees").Cells(r, 28).Value
    balancedue = Sheets("June 2017 SL Fees").Cells(r, 29).Value
    notes = Sheets("June 2017 SL Fees").Cells(r, 30).Value
    billingdate = Sheets("June 2017 SL Fees").Cells(r, 32).Value
    duedate = Sheets("June 2017 SL Fees").Cells(r, 31).Value
    pastdue = Sheets("June 2017 SL Fees").Cells(r, 27).Value
    
    Cells(r, 15).Value = "Detox"
    Cells(r, 15).Value = "INPT"
    Cells(r, 15).Value = "Discharged"
    Cells(r, 15).Value = ""
    Workbooks.Open ("C:\Users\SobaUser\Documents\SL Invoice\SimpleInvoice.xlsx")
    ActiveWorkbook.Sheets("Simple Invoice").Activate
    ActiveWorkbook.Sheets("Simple Invoice").Range("B11").Value = billingdate
    ActiveWorkbook.Sheets("Simple Invoice").Range("A16").Value = clientname
    ActiveWorkbook.Sheets("Simple Invoice").Range("A17").Value = address
    ActiveWorkbook.Sheets("Simple Invoice").Range("B23").Value = slrate
    ActiveWorkbook.Sheets("Simple Invoice").Range("B24").Value = location
    ActiveWorkbook.Sheets("Simple Invoice").Range("B25").Value = discount
    ActiveWorkbook.Sheets("Simple Invoice").Range("B26").Value = clientrate
    ActiveWorkbook.Sheets("Simple Invoice").Range("B27").Value = pastdue
    ActiveWorkbook.Sheets("Simple Invoice").Range("B28").Value = payments
    ActiveWorkbook.Sheets("Simple Invoice").Range("B29").Value = balancedue
    ActiveWorkbook.Sheets("Simple Invoice").Range("B33").Value = duedate
    ActiveWorkbook.Sheets("Simple Invoice").Range("A47").Value = notes
    
    path = "C:\Users\SobaUser\Documents\SL Invoice"
    ActiveWorkbook.SaveAs Filename:=path & clientname & "-" & billingdate & "-" & ".pdf"
    myfilename = ActiveWorkbook.FullName
    Application.DisplayAlerts = True
    'ActiveWorkbook.Printout copies:=1
    ActiveWorkbook.Close SaveChanges:=False
    
    nextrow:
    
    Next r
    
    End Sub
    Moderator's note: Please take the time to review our rules. There aren't many, and they are all important. Rule #3 requires code tags. I have added them for you this time because you are a new member. --6StringJazzer
    Last edited by 6StringJazzer; 06-14-2017 at 02:45 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Active X Command Button not working
    By gassiusmax in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-04-2015, 01:29 PM
  2. Command Button Stops Working After First Use
    By OpieWinston in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-03-2014, 06:55 PM
  3. Command Button Not working in new file
    By Fletch74 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-05-2013, 11:41 PM
  4. Command button code not working
    By mariposa in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-06-2011, 05:03 AM
  5. [SOLVED] Command button is not working by using VBA
    By Webtekr in forum Outlook Programming / VBA / Macros
    Replies: 1
    Last Post: 03-28-2009, 02:22 AM
  6. Command button not working properly on different sheet
    By Strikez in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-07-2007, 12:36 AM
  7. [SOLVED] command button isn't working
    By Nydia in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 04-29-2005, 06:06 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