Easy Userform question

  • Thread starter Thread starter David Jensen
  • Start date Start date
D

David Jensen

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
 
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)
 
It would be something like this:

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top