Fill label or textbox with data from array

pulpo

New Member
Joined
Feb 10, 2022
Messages
10
Office Version
  1. 2016
Platform
  1. Windows
Hello,
I have data in a range, let´s say A1:W1 and I have textbox or label (just to show information). I now want the the data from the range to show in my textbox the same as on my worksheet (from left to right). I tried using an array put the input method to the textbox won´t work.

VBA Code:
Sub arr()
Dim myarr As Variant
Dim i As Integer
myarr = Sheets(1).Range("A1:W1").Value

With TextBox1
    For i = LBound(myarr) To UBound(myarr)
        .Text = .Text & myarr(i)
    Next
End With

End Sub

Please help to solve this easy task.

Best regards
pulpo
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Try this:
Assuming we are dealing with the Range("A1:W1")
VBA Code:
Sub My_Script()
'Modified  2/10/2022  5:21:44 AM  EST
Application.ScreenUpdating = False
ActiveSheet.TextBox1.Value = ""
Dim i As Long
Dim ans As String
ans = ""
    For i = 23 To 1 Step -1
        ans = Cells(1, i).Value & " " & ans
    Next
ActiveSheet.TextBox1.Value = ans
Application.ScreenUpdating = True
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,832
Messages
6,121,854
Members
449,051
Latest member
excelquestion515

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top