ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Easy Userform question (https://www.excelbanter.com/excel-programming/295242-easy-userform-question.html)

David Jensen

Easy Userform question
 
Hi everyone. I apologize in advance for the simple question...

I have a userform with a textbox that a user will input a column identifier
into. For instance they will enter F in the textbox and after clicking the
command button on the bottom of the form the program will select the entire
column F and replace each instance of, say, the word "end" with the word
"final". It will do more than this but I just need help getting started on
how to select the column based on the user's input into the textbox on the
userform.

Thanks in advance so much for the help.

Dave



Bob Phillips[_6_]

Easy Userform question
 
Hi David,

Here is a starter

Private Sub CommandButton1_Click()
Dim iCol As Long
With TextBox1
If Len(.Text) 2 Then
MsgBox "Invalid entry"
ElseIf Len(.Text) = 2 Then
iCol = 26 * (Asc(Left(.Text, 1)) - 64) + Asc(Right(.Text, 1)) -
64
Else
iCol = Asc(.Text) - 64
End If
End With
MsgBox iCol
ActiveSheet.Columns(iCol).Replace _
What:="end", _
Replacement:="final", _
LookAt:=xlPart, _
SearchOrder:=xlByRows, _
MatchCase:=False
End Sub


--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"David Jensen" wrote in message
...
Hi everyone. I apologize in advance for the simple question...

I have a userform with a textbox that a user will input a column

identifier
into. For instance they will enter F in the textbox and after clicking

the
command button on the bottom of the form the program will select the

entire
column F and replace each instance of, say, the word "end" with the word
"final". It will do more than this but I just need help getting started

on
how to select the column based on the user's input into the textbox on the
userform.

Thanks in advance so much for the help.

Dave





Robin Hammond[_2_]

Easy Userform question
 

It would be something like this:

Private Sub CommandButton1_Click()
Range(txt1.Text & ":" & txt1.Text).Select
End Sub


--
Robin Hammond
www.enhanceddatasystems.com
"David Jensen" wrote in message
...
Hi everyone. I apologize in advance for the simple question...

I have a userform with a textbox that a user will input a column

identifier
into. For instance they will enter F in the textbox and after clicking

the
command button on the bottom of the form the program will select the

entire
column F and replace each instance of, say, the word "end" with the word
"final". It will do more than this but I just need help getting started

on
how to select the column based on the user's input into the textbox on the
userform.

Thanks in advance so much for the help.

Dave






All times are GMT +1. The time now is 04:00 AM.

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