+ Reply to Thread
Results 1 to 8 of 8

userform data capturing in next available row

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Wisbech England
    MS-Off Ver
    Excel 2010
    Posts
    308

    userform data capturing in next available row

    Hi
    I am having some problems with either my code or workbook formatting.
    Problem is that This code works well in my other sheet in the same workbook but not on the other sheets it doesn't capturing the data from userform in the next empty row instead it's putting the data into the row 48??? I have checked it and all rows from 1 to 47 are empty but for some reason it doesn't see it or thinks these rows containing some data. This is very strange, I have selected all rows and click delete but it didn't hep at all.
    Any suggestions please?

    Thank You

    Private Sub cmdSubmit_Click()
       Dim rw As Long    'next available row
     
       With ActiveSheet
     
          'get the next avialable row in ActiveSheet
          rw = .Range("A" & .Rows.Count).End(xlUp).Row + 1
     
          'put the text box values in this row
          .Range("A" & rw).Value = txtName.Value
          .Range("B" & rw).Value = txtShift.Value
     
          'copy the formula from the previous row
          .Range("C" & rw - 1 & ":G" & rw - 1).Copy
          .Range("C" & rw & ":G" & rw).PasteSpecial Paste:=xlPasteFormulas
          Application.CutCopyMode = False
       End With
     
       '================================
       'OPTIONAL - clear the text boxes
       '================================
       'txtName.Value = ""
       'txtAge.Value = ""
     
       '==========================
       'OPTIONAL - unload the form
       '==========================
       'unload me
    End Sub

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: userform data capturing in next available row

    Your cursor has to be on the active sheet before you run it.

  3. #3
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: userform data capturing in next available row

    Do you have formulas on these rows? If so, they may be not empty, but are null strings.

  4. #4
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Wisbech England
    MS-Off Ver
    Excel 2010
    Posts
    308

    Re: userform data capturing in next available row

    Thanks for your replays.
    No I do not have any formulas in those rows and this is very strange basically the format is identical to the one where the code is fully working I do not understand this at all.

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: userform data capturing in next available row

    I suspect these rows are not empty. One way to test if any row in column A is empty.

    Sub Areuempty()
    Dim rw&, i&
    With ActiveSheet
    
        rw = .Range("A" & .Rows.count).End(xlUp).Row
        
        For i = 1 To rw
        
            If IsEmpty(.Cells(i, 1)) Then
                MsgBox "It is empty cell"
            Else
                MsgBox "It is not empty cell"
            End If
        Next
    
    End With
    
    End Sub

  6. #6
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Wisbech England
    MS-Off Ver
    Excel 2010
    Posts
    308

    Re: userform data capturing in next available row

    Thanks I will try this tomorrow and let you know.

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: userform data capturing in next available row

    Or use this code to clear cells if the last row is 47.

    Sub testr()
    
    With ActiveSheet
    
        .Range("A1").Resize(.Range("A" & .Rows.count).End(xlUp).Row + 1).Clear
       
    End With
    
    End Sub

  8. #8
    Forum Contributor
    Join Date
    08-29-2011
    Location
    Wisbech England
    MS-Off Ver
    Excel 2010
    Posts
    308

    Re: userform data capturing in next available row

    Ok managed to fix this.
    There was something in cell 46 but wasn't visible all I've done was I've selected everything and clear the content.

    Thanks for help

+ 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. Filter not capturing Data
    By NYC4LIFE in forum Excel General
    Replies: 1
    Last Post: 07-24-2013, 04:07 PM
  2. Capturing data from another table
    By rayzorkat in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-03-2013, 09:59 AM
  3. [SOLVED] Capturing matched data from one tab to another
    By FiBell in forum Excel General
    Replies: 3
    Last Post: 09-25-2012, 07:35 AM
  4. Capturing data from a userform to a worksheet
    By goldbeje in forum Excel General
    Replies: 0
    Last Post: 08-29-2012, 07:22 PM
  5. Capturing Data
    By mikello in forum Excel General
    Replies: 2
    Last Post: 10-22-2009, 05:13 AM

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