VBA Userform not updating to spreadsheet

hurricanedaphne

New Member
Joined
Nov 9, 2010
Messages
8
I've created my first userform and it is not updating to a spreadsheet upon Save. I've read numerous articles & copied & pasted code with appropriate changes for names, and the closest I got was the combo boxes would cause an error - when I made those lines 'comments', then the text lines would update to the column headers only. I've made my combo list data into dynamic tables, I tried other code I found, but I'm stuck. I would really appreciate some help.
Here's my table for the user form to update: I see in the preview the headers aren't showing, but they are the same as the userform and of course the VBA code farther down.

StatusEstimatorProject NameProject AddressDate SubmittedClientBid AmountBid TypeProject TypeCompetitorsWinning GCNotification DateNotesFee
UndecidedMH1125 Schilling Blvd1125 Schilling 5/15/2020Boyle$60,787CompetativeOffice TIA&R
BiddingBL6060 Poplar Ave6060 Poplar 5/28/2020BoyleOffice TI
LossBLAltana569 N. McClean5/14/2020$1,534,440CompetativeGround UpMetro, GTGGot beat by $130k
WinSCDesoto TourismSouthaven, MSAERC$330,000CompetativeOffice TI Nickson


Here's my backup for the combo boxes:

Project Tracker for Forum.xlsm
ABCD
1StatusEstimatorBid TypeProject Type
2BiddingBCBudget/CompetativeExterior
3DeadBLBudget/Single SourceGround Up
4LossBSCompetativeIndustrial TI
5UndecidedDMNegotiated Medical
6WinDWOH&POffice TI
7FSOpen BidOther
8HTRetail TI
9JB
10MH
11RS
12RW
13SC
Backup


I've attached a snip of my userform: All combo boxes have correct row-reference in properties
User Form Snip.PNG
of the named ranges on the backup sheet.

And finally - the code that isnt' working. It will 'clear' the form, but not update the spreadsheet. I apologize for the length of the post and any/all help will be greatly appreciated!

VBA Code:
Private Sub cmdAddProject_Click()

    'Copy input values to sheet.
    Dim lRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("Project List")
    lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
    With ws
        .Cells(l, 1).Value = Me.cboStatus.Value
        .Cells(l, 2).Value = Me.cboEstimator.Value
        .Cells(1, 3).Value = Me.ProjectName.Value
        .Cells(1, 4).Value = Me.ProjectAddress.Value
        .Cells(1, 5).Value = Me.DateSubmitted.Value
        .Cells(1, 6).Value = Me.Client.Value
        .Cells(1, 7).Value = Me.BidAmount.Value
        .Cells(1, 8).Value = Me.cboBidType.Value
        .Cells(1, 9).Value = Me.cboProjectType.Value
        .Cells(1, 10).Value = Me.Competitors.Value
        .Cells(1, 11).Value = Me.WinningGC.Value
        .Cells(1, 12).Value = Me.NotificationDate.Value
        .Cells(1, 13).Value = Me.Notes.Value
        .Cells(1, 14).Value = Me.Fee.Value
        
        
        
    End With
    'Clear input controls.
    Me.cboStatus.Value = ""
    Me.cboEstimator.Value = ""
    Me.ProjectName.Value = ""
    Me.ProjectAddress.Value = ""
    Me.DateSubmitted.Value = ""
    Me.Client.Value = ""
    Me.BidAmount.Value = ""
    Me.cboBidType.Value = ""
    Me.cboProjectType.Value = ""
    Me.Competitors.Value = ""
    Me.WinningGC.Value = ""
    Me.NotificationDate.Value = ""
    Me.Notes.Value = ""
    Me.Fee.Value = ""
    
End Sub
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Difficult to say what is going on without being able to test.

Anyways, since the bottom part of the code works, I can only ask if the spreadsheet to be updated is named 'Project List"?
 
Upvote 0
.
With the benefit of having your workbook here to experiment with ... I believe the following is what you are seeking :

VBA Code:
Private Sub cmdAddProject_Click()

    'Copy input values to sheet.
    Dim ws As Worksheet
    Dim newRow As Long
    
    Set ws = Worksheets("Project List")
    newRow = Application.WorksheetFunction.CountA(ws.Range("A:A")) + 1
    
    With ws
        ws.Cells(newRow, 1).Value = Me.cboStatus.Value
        ws.Cells(newRow, 2).Value = Me.cboEstimator.Value
        ws.Cells(newRow, 3).Value = Me.ProjectName.Value
        ws.Cells(newRow, 4).Value = Me.ProjectAddress.Value
        ws.Cells(newRow, 5).Value = Me.DateSubmitted.Value
        ws.Cells(newRow, 6).Value = Me.Client.Value
        ws.Cells(newRow, 7).Value = Me.BidAmount.Value
        ws.Cells(newRow, 8).Value = Me.cboBidType.Value
        ws.Cells(newRow, 9).Value = Me.cboProjectType.Value
        ws.Cells(newRow, 10).Value = Me.Competitors.Value
        ws.Cells(newRow, 11).Value = Me.WinningGC.Value
        ws.Cells(newRow, 12).Value = Me.NotificationDate.Value
        ws.Cells(newRow, 13).Value = Me.Notes.Value
        ws.Cells(newRow, 14).Value = Me.Fee.Value
    End With
    
    'Clear input controls.
    Me.cboStatus.Value = ""
    Me.cboEstimator.Value = ""
    Me.ProjectName.Value = ""
    Me.ProjectAddress.Value = ""
    Me.DateSubmitted.Value = ""
    Me.Client.Value = ""
    Me.BidAmount.Value = ""
    Me.cboBidType.Value = ""
    Me.cboProjectType.Value = ""
    Me.Competitors.Value = ""
    Me.WinningGC.Value = ""
    Me.NotificationDate.Value = ""
    Me.Notes.Value = ""
    Me.Fee.Value = ""
    
End Sub
 
Upvote 0
Yes, it's name Project List :)

Here's a snip of a 'test', the error code I got, and the line that's highlighted yellow with 'debug': .Cells(l, 1).Value = Me.cboStatus.Value
Since it's the first line, I assume the others will too.

Capture.PNG


If I 'comment' the cbo code lines, the text boxes will update in the 'Project List' spreadsheet - but only in the top header row:.
Capture1.PNG
 
Upvote 0
.
With the benefit of having your workbook here to experiment with ... I believe the following is what you are seeking :

VBA Code:
Private Sub cmdAddProject_Click()

    'Copy input values to sheet.
    Dim ws As Worksheet
    Dim newRow As Long
   
    Set ws = Worksheets("Project List")
    newRow = Application.WorksheetFunction.CountA(ws.Range("A:A")) + 1
   
    With ws
        ws.Cells(newRow, 1).Value = Me.cboStatus.Value
        ws.Cells(newRow, 2).Value = Me.cboEstimator.Value
        ws.Cells(newRow, 3).Value = Me.ProjectName.Value
        ws.Cells(newRow, 4).Value = Me.ProjectAddress.Value
        ws.Cells(newRow, 5).Value = Me.DateSubmitted.Value
        ws.Cells(newRow, 6).Value = Me.Client.Value
        ws.Cells(newRow, 7).Value = Me.BidAmount.Value
        ws.Cells(newRow, 8).Value = Me.cboBidType.Value
        ws.Cells(newRow, 9).Value = Me.cboProjectType.Value
        ws.Cells(newRow, 10).Value = Me.Competitors.Value
        ws.Cells(newRow, 11).Value = Me.WinningGC.Value
        ws.Cells(newRow, 12).Value = Me.NotificationDate.Value
        ws.Cells(newRow, 13).Value = Me.Notes.Value
        ws.Cells(newRow, 14).Value = Me.Fee.Value
    End With
   
    'Clear input controls.
    Me.cboStatus.Value = ""
    Me.cboEstimator.Value = ""
    Me.ProjectName.Value = ""
    Me.ProjectAddress.Value = ""
    Me.DateSubmitted.Value = ""
    Me.Client.Value = ""
    Me.BidAmount.Value = ""
    Me.cboBidType.Value = ""
    Me.cboProjectType.Value = ""
    Me.Competitors.Value = ""
    Me.WinningGC.Value = ""
    Me.NotificationDate.Value = ""
    Me.Notes.Value = ""
    Me.Fee.Value = ""
   
End Sub
I updated with your line changes above and I still get a 'run-time' error. The error is on the first cbo updating line: .Cells(newRow, 1).Value = Me.cboStatus.Value

I don't know what is wrong with it, the row-source data is correct in the properties, I see the entire list available in the combo box - including additions.

Does it make a difference if the data is a 'dynamic named range' vs. a 'dynamic table'? I started out with the 'named range' and one of those articles I read said always use tables, so I changed the backup lists to tables.


VBA Code:
Private Sub cmdAddProject_Click()

    'Copy input values to sheet.
    Dim ws As Worksheet
    Dim newRow As Long
    
    Set ws = Worksheets("Project List")
    
    newRow = Application.WorksheetFunction.CountA(ws.Range("A:A")) + 1
    
    With ws
        .Cells(l, 1).Value = Me.cboStatus.Value
        .Cells(l, 2).Value = Me.cboEstimator.Value
        .Cells(1, 3).Value = Me.ProjectName.Value
        .Cells(1, 4).Value = Me.ProjectAddress.Value
        .Cells(1, 5).Value = Me.DateSubmitted.Value
        .Cells(1, 6).Value = Me.Client.Value
        .Cells(1, 7).Value = Me.BidAmount.Value
        .Cells(1, 8).Value = Me.cboBidType.Value
        .Cells(1, 9).Value = Me.cboProjectType.Value
        .Cells(1, 10).Value = Me.Competitors.Value
        .Cells(1, 11).Value = Me.WinningGC.Value
        .Cells(1, 12).Value = Me.NotificationDate.Value
        .Cells(1, 13).Value = Me.Notes.Value
        .Cells(1, 14).Value = Me.Fee.Value
        
        
        
    End With
 
Upvote 0
.
With the benefit of having your workbook here to experiment with ... I believe the following is what you are seeking :

VBA Code:
Private Sub cmdAddProject_Click()

    'Copy input values to sheet.
    Dim ws As Worksheet
    Dim newRow As Long
   
    Set ws = Worksheets("Project List")
    newRow = Application.WorksheetFunction.CountA(ws.Range("A:A")) + 1
   
    With ws
        ws.Cells(newRow, 1).Value = Me.cboStatus.Value
        ws.Cells(newRow, 2).Value = Me.cboEstimator.Value
        ws.Cells(newRow, 3).Value = Me.ProjectName.Value
        ws.Cells(newRow, 4).Value = Me.ProjectAddress.Value
        ws.Cells(newRow, 5).Value = Me.DateSubmitted.Value
        ws.Cells(newRow, 6).Value = Me.Client.Value
        ws.Cells(newRow, 7).Value = Me.BidAmount.Value
        ws.Cells(newRow, 8).Value = Me.cboBidType.Value
        ws.Cells(newRow, 9).Value = Me.cboProjectType.Value
        ws.Cells(newRow, 10).Value = Me.Competitors.Value
        ws.Cells(newRow, 11).Value = Me.WinningGC.Value
        ws.Cells(newRow, 12).Value = Me.NotificationDate.Value
        ws.Cells(newRow, 13).Value = Me.Notes.Value
        ws.Cells(newRow, 14).Value = Me.Fee.Value
    End With
   
    'Clear input controls.
    Me.cboStatus.Value = ""
    Me.cboEstimator.Value = ""
    Me.ProjectName.Value = ""
    Me.ProjectAddress.Value = ""
    Me.DateSubmitted.Value = ""
    Me.Client.Value = ""
    Me.BidAmount.Value = ""
    Me.cboBidType.Value = ""
    Me.cboProjectType.Value = ""
    Me.Competitors.Value = ""
    Me.WinningGC.Value = ""
    Me.NotificationDate.Value = ""
    Me.Notes.Value = ""
    Me.Fee.Value = ""
   
End Sub
Crap - hold on - I didn't change everything...I'm sorry! I'll try again & let you know.
 
Upvote 0
You are using your own macro ... that is why you are receiving the errors.

You MUST paste my edited macro either above or below your macro. Change the name of your macro to something else. Then try it.
 
Upvote 0
Ok .. glad it is working for you.

Cheers !
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top