ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA- inserting multiple cell values into single textbox (https://www.excelbanter.com/excel-programming/355949-vba-inserting-multiple-cell-values-into-single-textbox.html)

VBA_MAN

VBA- inserting multiple cell values into single textbox
 

Hi All,

Just wanted to know the code for inserting 3-4 cells values on a excel
sheet into a single text box on a userform. I think it might be the
offset property not sure. E.g

Range A1-D1 need the contents of all those to go into a single text box
which is created on a userform. These will automatically be added to the
text box when you press a commandbutton on the excel sheet

help?

regards


--
VBA_MAN
------------------------------------------------------------------------
VBA_MAN's Profile: http://www.excelforum.com/member.php...o&userid=32437
View this thread: http://www.excelforum.com/showthread...hreadid=522106


cheesey_toastie

VBA- inserting multiple cell values into single textbox
 
You dont need to use the offset but this is the simpliest way.


Dim rngmyrange As Range

'Change the sheet name to the relevant sheet
Set rngmyrange = ActiveWorkbook.Sheets("Sheet1").Range("A1")

'change dialogsheets(1).editboxes(1) to represent your userform and
text box names...
DialogSheets(1).EditBoxes(1).Text = ngmyrange.Offset(0, 0) &
rngmyrange.Offset(0, 1) & rngmyrange.Offset(0, 2) &
rngmyrange.Offset(0, 3)


' you might want to add in some spaces or commas ..
'ngmyrange.Offset(0, 0) & ", " & rngmyrange.Offset(0, 1) etc...


cheesey_toastie

VBA- inserting multiple cell values into single textbox
 
Slight typo...

Dim rngmyrange As Range

'Change the sheet name to the relevant sheet
Set rngMyRange = ActiveWorkbook.Sheets("Sheet1").Range("A1")

'change dialogsheets(1).editboxes(1) to represent your userform and
text box names...
DialogSheets(1).EditBoxes(1).Text = rngMyRange.Offset(0, 0) &
rngMyRange.Offset(0, 1) & rngMyRange.Offset(0, 2) &
rngMyRange.Offset(0, 3)

' you might want to add in some spaces or commas ..
'rngMyRange.Offset(0, 0) & ", " & rngMyRange.Offset(0, 1) etc...



All times are GMT +1. The time now is 01:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com