Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 11th, 2013, 04:08 PM
Registered User
 
Join Date: Dec 2013
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Default ComboBox Save Select to a Specific Row and Column

I have an excel vba form with a comboBox and listBox. I'm saving the listbox items to the last empty row in a column. I'm trying to save the comboBox selection using the same last empty row as the listbox and move 1 column left.

Code:
Private Sub CmdUpdate_Click()
    
    Dim ws As Worksheet
    Dim x As Long, lRow As Integer
    
    lRow = Sheets("sheet1").Range("B" & Rows.Count).End(xlUp).Row
    lRow = lRow + 1
    
        If CboProjectList = "" Then
            MsgBox "Select Project Number"
            Else
            
            If CboProjectList > "" Then
                Worksheets("Sheet1").Range("a2").Value = CboProjectList.Value
                Else
                End If
                
                If LstBxNwItems.ListIndex = -1 Then
                    MsgBox "Please Add Deliverables"
                    Else
            
                    For x = 0 To LstBxNwItems.ListCount - 1
                        Range("b" & lRow + x) = LstBxNwItems.List(x)
                        Next x
                    End If
                End If
            
            
  LstBxNwItems.Clear
  CboProjectList.Clear
  CboProjectList.SetFocus
    
End Sub
 
Old December 12th, 2013, 01:19 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

Code:
For x = 0 To LstBxNwItems.ListCount - 1
                        Range("b" & lRow + x) = LstBxNwItems.List(x)
                        Next x
                    End If
lRow = Sheets("sheet1").Range("B" & Rows.Count).End(xlUp).Row
    
Range("b" & lRow + 1) = CboProjectList.Value
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
The Following User Says Thank You to Shasur For This Useful Post:
wstring (December 18th, 2013)





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to get the column names row by row for the given xml using xslt Smiley XSLT 0 August 5th, 2013 04:10 AM
Save 2 Worksheets As New File To Specific Folder nevidim_ Excel VBA 0 June 6th, 2013 08:58 AM
save content combobox tankfrank35 Beginning VB 6 4 September 26th, 2007 08:16 AM
Get specific row from database Lofa ASP.NET 1.0 and 1.1 Basics 9 July 11th, 2007 01:17 PM
Read a column and Search Row by Row in another col AyatKh Excel VBA 2 January 26th, 2005 12:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.