+ Reply to Thread
Results 1 to 2 of 2

Problem copying values to a worksheet

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    04-11-2012
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    245

    Problem copying values to a worksheet

    After choosing a value from a ComboBox the following code executes. However, it's placing the selected value in column C in the "first blank row". I need the value to be placed in the "first row" even if this row contains values in other cells. By the way, the first row containing data is row 6. My column headers are displayed across row 5.
    Private Sub cmdAdd_Click()
    
     'Copy input values to sheet.
     Dim RowCount As Long
     Dim lRow As Long
     Dim ws As Worksheet
     Set ws = Worksheets("Test")
     lRow = ws.Cells(Rows.count, 1).End(xlUp).Offset(1, 0).Row
     With ws
    
     .Cells(lRow, 3).Value = Me.cboCode.Value
    
     End With
    
     'Clear input controls.
     Me.cboCode.Value = ""
    Thanks!
    Last edited by JBeaucaire; 12-12-2014 at 02:43 AM.

  2. #2
    Forum Contributor
    Join Date
    03-04-2014
    Location
    Canada Eh
    MS-Off Ver
    Excel 2010
    Posts
    199

    Re: Problem copying values to a worksheet

    Try
    Private Sub cmdAdd_Click()
    
     'Copy input values to sheet.
     Dim RowCount As Long
     Dim lRow As Long
     Dim ws As Worksheet
     Set ws = Worksheets("Test")
     lRow = ws.Cells(Rows.count, 1).End(xlUp).Row
     With ws
    
     .Cells(lRow, 3).Value = Me.cboCode.Value
    
     End With
    
     'Clear input controls.
     Me.cboCode.Value = ""
    All I did was remove the Offset.
    Click the * to give Rep to a post you like.

+ 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. Copying cells dynamically to a worksheet based on values in another worksheet
    By freelance in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-10-2013, 01:45 PM
  2. Problem while copying worksheet
    By Abhijit2011 in forum Excel General
    Replies: 2
    Last Post: 11-24-2011, 07:34 AM
  3. Problem copying array values to worksheet cells
    By CoolGal in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-16-2008, 02:00 AM
  4. [SOLVED] Copying worksheet problem
    By owl37 in forum Excel General
    Replies: 0
    Last Post: 01-10-2006, 06:15 AM
  5. [SOLVED] Copying Worksheet Problem - Names
    By Paul Smith in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-03-2005, 03:05 PM

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