chroniclesofdave
New Member
- Joined
- Aug 8, 2016
- Messages
- 48
Ok, I have working code that looks like this:
And it works great, but I am trying to have each copied cells data paste into a different textbox in page 1 of the user form. So far I have this:
But the code keeps throwing an error on
The error is "Run-time error '-2147024809 (80070057': Could not find the specified object." I keep hitting my head on the desk to jar an idea, and i know it probably had to do with the page1 not being cited, but i can't figure out how to incorporate it. any help is appreciated.
Code:
Private Sub CommandButton39_Click()
Dim objWorkbook As Workbook
Dim i As Integer
Dim arrIn As Variant
Dim arrOut()
Dim j As Long
Dim counter As Long
Dim outRow As Long
Dim sUser As String
Set objWorkbook = Workbooks.Open( _
"C:\Documents\Data.xlsm")
sUser = "user1"
With Sheets("Final").Range("A1").CurrentRegion
arrIn = .Value
counter = Application.CountIf(.Columns(2), sUser)
ReDim arrOut(1 To counter)
outRow = 1
For i = 1 To UBound(arrIn)
If VBA.LCase$(arrIn(i, 2)) = sUser Then
For j = 1 To UBound(arrIn, 2) - 1
arrOut(outRow) = arrOut(outRow) & arrIn(i, j) & vbTab
Next j
arrOut(outRow) = arrOut(outRow) & arrIn(i, j)
outRow = outRow + 1
End If
Next i
objWorkbook.Close SaveChanges:=False
With TextBox4
.MultiLine = True
.Value = Join(arrOut, vbCrLf)
End With
End With
On Error Resume Next
End Sub
And it works great, but I am trying to have each copied cells data paste into a different textbox in page 1 of the user form. So far I have this:
Code:
Private Sub CommandButton39_Click()
Dim objWorkbook As Workbook
Dim i As Integer
Dim arrIn As Variant
Dim arrOut()
Dim j As Long
Dim counter As Long
Dim outRow As Long
Dim sUser As String
Set objWorkbook = Workbooks.Open( _
"C:\Documents\Data.xlsm")
sUser = "user1"
With Sheets("Final").Range("A1").CurrentRegion
arrIn = .Value
counter = Application.CountIf(.Columns(2), sUser)
For i = 1 To UBound(arrIn)
If VBA.LCase$(arrIn(i, 2)) = sUser Then
For j = 1 To UBound(arrIn, 2) - 1
outRow = outRow + 1
Me.Controls("textbox" & outRow) = arrIn(i, j)
Next j
End If
Next i
objWorkbook.Close SaveChanges:=False
End With
On Error Resume Next
End Sub
Code:
Me.Controls("textbox" & outRow) = arrIn(i, j)