Userforms

  • Thread starter Thread starter Swift2003
  • Start date Start date
S

Swift2003

Any ideas on what sort of code is needed so text entered into a userfor
textbox can be set as sheet header/footer ???

thanks 4 any hel
 
This will put your text into the Center Header of a Worksheet

on Pushing a command Button

Private Sub CommandButton1_Click()

With ActiveSheet.PageSetup
.CenterHeader = TextBox1.Text
End With
End Sub

Just alter as Needed

HTH

Dav
 
Thats quality thanx, do you know though how i could validate what the
input

ie
Say i only want a 5 digit number to be entered into the textbox
if any other number number or value is entered an error message appear
 
Swift2003,

Code
-------------------
Private Sub CommandButton1_Click()

If Not IsNumeric(TextBox1.Text) Then
Msgbox "Please enter a 5 digit number", vbInformation
TextBox1.SetFocus
TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1.Text)
Exit Sub
End If

If Len(TextBox1.Text) <> 5 Then
Msgbox "Please enter a 5 digit number", vbInformation
TextBox1.SetFocus
TextBox1.SelStart = 0
TextBox1.SelLength = Len(TextBox1.Text)
Exit Sub
End If

With ActiveSheet.PageSetup
.CenterHeader = TextBox1.Text
End With

End Su
 

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