ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Categories (https://www.excelbanter.com/excel-programming/419332-categories.html)

Art

Categories
 
Hello all:

I am making a userform with a text box and a RefEdit button. The user enters
text in the textbox, and then selects a range with the RefeEdit. Now I need
to apply the word from the text box in each cell from the range. However I
need the current text in the range should stay, just the text from the text
box should be "Added" before the original text.

Please help me figure this out.

Thanks.

DMoney

Categories
 
untested -- but might work


For Each c In 'the range you want to use
c.Formula = textbox1.text & c.value
End If
Next



"art" wrote:

Hello all:

I am making a userform with a text box and a RefEdit button. The user enters
text in the textbox, and then selects a range with the RefeEdit. Now I need
to apply the word from the text box in each cell from the range. However I
need the current text in the range should stay, just the text from the text
box should be "Added" before the original text.

Please help me figure this out.

Thanks.


Art

Categories
 
Something is wrong. First the error was end with out if. So I took it out.
The the error was on the first line: For Each c In Categories.RefEdit1.Value.
Please help me finish this.

Thanks for your help.



"dmoney" wrote:

untested -- but might work


For Each c In 'the range you want to use
c.Formula = textbox1.text & c.value
End If
Next



"art" wrote:

Hello all:

I am making a userform with a text box and a RefEdit button. The user enters
text in the textbox, and then selects a range with the RefeEdit. Now I need
to apply the word from the text box in each cell from the range. However I
need the current text in the range should stay, just the text from the text
box should be "Added" before the original text.

Please help me figure this out.

Thanks.


keiji kounoike

Categories
 
I don't know what your Categories in Categories.RefEdit1.Value means. Is
that your object name of your Userform?
Anyway, add the commandbutton in your userform and try the code below.
first, input data in both textbox and refedit, then click the commandbutton.

Private Sub CommandButton1_Click()
Dim rng As Range
For Each rng In Range(Me.RefEdit1.Value)
rng.Value = Me.TextBox1.Value & rng.Value
Next
End Sub

keiji

art wrote:
Something is wrong. First the error was end with out if. So I took it out.
The the error was on the first line: For Each c In Categories.RefEdit1.Value.
Please help me finish this.

Thanks for your help.



"dmoney" wrote:

untested -- but might work


For Each c In 'the range you want to use
c.Formula = textbox1.text & c.value
End If
Next



"art" wrote:

Hello all:

I am making a userform with a text box and a RefEdit button. The user enters
text in the textbox, and then selects a range with the RefeEdit. Now I need
to apply the word from the text box in each cell from the range. However I
need the current text in the range should stay, just the text from the text
box should be "Added" before the original text.

Please help me figure this out.

Thanks.



All times are GMT +1. The time now is 12:28 PM.

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