VBA Remove blank space

Aretradeser

Board Regular
Joined
Jan 16, 2013
Messages
176
Office Version
  1. 2013
Platform
  1. Windows
I use a UserForm with several controls for data entry to an Excel sheet.
In one of the columns of this sheet, I enter the values of 3 linked TextBoxes: the first 2 values (TextBox2 and TextBox3), separated by a blank space. The third value (TextBox1), separated from the value of TextBox2 by a ",". The issue is that between the TextBox3 value and the "," there is a blank space and I need it not to be like that; that is, the last letter of the TextBox3 value to be followed by the "," with no blank spaces.
The values of the 3 TextBoxes are text.
VBA Code:
CODE:
With Worksheets("DATA")
            t = Cells(Rows.Count, 2).End(xlUp).Row
            Cells(t + 1, 2) = TextBox2 & " " & TextBox3 & ", " & TextBox1
            Cells(t + 1, 3) = ComboBox5
            Cells(t + 1, 4) = ComboBox6
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
That sounds as though you have a space at the end of value in textbox3
 
Upvote 0
Oh no. Sorry. I miss read.

Yes I would agree with fluff.

Would trim(textbox3) work.
 
Upvote 0
just incase

VBA Code:
With Worksheets("DATA")
            t = Cells(Rows.Count, 2).End(xlUp).Row
            Cells(t + 1, 2) = TextBox2 & " " & trim(TextBox3) & ", " & TextBox1
            Cells(t + 1, 3) = ComboBox5
            Cells(t + 1, 4) = ComboBox6
 
Upvote 0
Solution

Forum statistics

Threads
1,215,491
Messages
6,125,098
Members
449,205
Latest member
ralemanygarcia

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