Results 1 to 5 of 5

Thread: VBA Code to Copy UserForm Textbox data to specific Excel sheet/cells

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Administrator VBAX Master georgiboy's Avatar
    Joined
    Mar 2008
    Location
    Kent, England
    Posts
    1,308
    Location
    The below and attached may help:
    Private Sub CommandButton1_Click()
        Dim nCol As Integer
        Dim nRow As Integer
        Dim myArray() As Variant
        Dim i As Integer
        Dim j As Integer
        
        nCol = 3
        nRow = 6
        
        ReDim myArray(1 To nCol, 1 To nRow)
        
        For i = 1 To nCol
            For j = 1 To nRow
                myArray(i, j) = Me.Controls("TextBox" & ((i - 1) * nRow + j)).Value
            Next j
        Next i
        
        Range("A1").Resize(nRow, nCol) = Application.Transpose(myArray)
    End Sub
    Attached Files Attached Files
    Click here for a guide on how to add code tags
    Click here for a guide on how to mark a thread as solved
    Click here for a guide on how to upload a file with your post

    Excel 365, Version 2408, Build 17928.20080

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •