Userform as input box

pantakos

Board Regular
Joined
Oct 10, 2012
Messages
161
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Hello all!

There is need (in order to msgbox works in MacOs - Greek charcter issues) , the below code to be transform with userform and not message box

My mind is stuck!

Can you please help?

VBA Code:
Sub SheetsFromTemplate()
 Dim ActNm As String
  ActNm = InputBox("Please enter job title")
If ActNm = "" Then
MsgBox ("Input canceled!")
Exit Sub
Else
 ActiveWorkbook.Sheets("JOB").Visible = True
 ActiveWorkbook.Sheets("JOB").Copy _
 After:=ActiveWorkbook.Sheets("WORKHOUSE")
 ActiveSheet.Name = ActNm
 
ActiveWorkbook.Sheets("JOB").Visible = False
End If

End Sub

Thank you !
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I hope Excel for Mac doesn't differ significantly where userforms are concerned, but this was what I did to create a userform which accomplishes what your macro did.

First, create a userform. Add a label, a textbox control (name it tbTemplate), and a command button control (name that cmdGo).

VBA Code:
Private Sub cmdGo_Click()

If tbTemplate.Value = "" Then

  MsgBox "You must provide a template name!", vbCritical
  Exit Sub

Else

  With ActiveWorkbook
    
    .Sheets("JOBS").Visible = True
    .Sheets("JOBS").Copy After:=.Sheets("WORKHOUSE")
    ActiveSheet.Name = tbTemplate.Value

  End With

End If

Unload Me

End Sub
 

Attachments

  • MrExcel0314_02.PNG
    MrExcel0314_02.PNG
    22 KB · Views: 9
Upvote 0
Solution
I hope Excel for Mac doesn't differ significantly where userforms are concerned, but this was what I did to create a userform which accomplishes what your macro did.

First, create a userform. Add a label, a textbox control (name it tbTemplate), and a command button control (name that cmdGo).

VBA Code:
Private Sub cmdGo_Click()

If tbTemplate.Value = "" Then

  MsgBox "You must provide a template name!", vbCritical
  Exit Sub

Else

  With ActiveWorkbook
   
    .Sheets("JOBS").Visible = True
    .Sheets("JOBS").Copy After:=.Sheets("WORKHOUSE")
    ActiveSheet.Name = tbTemplate.Value

  End With

End If

Unload Me

End Sub
Yes! That worked like a charm!

Thank you !
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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