ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   VBA in Excel (https://www.excelbanter.com/excel-discussion-misc-queries/22019-vba-excel.html)

Carol

VBA in Excel
 
I want to create a template in Excel, such that when you open it, a dialog
box will pop up asking for Customer Name, etc. and once you fill in those
fields and click "Ok," then the fields in the worksheet will then be
populated with that information. I have done this in MS Word using bookmarks,
but I'm not sure how to do it in Excel. Can anyone help me? Many Thanks!

Dave Peterson

Debra Dalgleish has a get started with userforms at:
http://www.contextures.com/xlUserForm01.html

Debra has a section to run the userform from a button:
http://www.contextures.com/xlUserForm01.html#Open

But you'll want to use a macro that runs each time you open that workbook:

Option Explicit
sub auto_open()
userform1.show
end sub

is one way.

Carol wrote:

I want to create a template in Excel, such that when you open it, a dialog
box will pop up asking for Customer Name, etc. and once you fill in those
fields and click "Ok," then the fields in the worksheet will then be
populated with that information. I have done this in MS Word using bookmarks,
but I'm not sure how to do it in Excel. Can anyone help me? Many Thanks!


--

Dave Peterson

Jonathan Cooper

In A1:E1 type the following:

Customer Name Street Address City State Zip

Go to Tools--Macro--record new macro in this workbook.

Move your cursor down one cell or something and then hit the stop button.
This is just my simple way to create the VBA module in this workbook.

Now hit Alt+F11. This will open VBA. Find the macro you just created and
paste over top of it with the following.

Sub Auto_Open()
'
' Auto_Open Macro
'
ActiveSheet.ShowDataForm
End Sub

Save and close the workbook. Open the workbook again, and you should get
prompted.




"Carol" wrote:

I want to create a template in Excel, such that when you open it, a dialog
box will pop up asking for Customer Name, etc. and once you fill in those
fields and click "Ok," then the fields in the worksheet will then be
populated with that information. I have done this in MS Word using bookmarks,
but I'm not sure how to do it in Excel. Can anyone help me? Many Thanks!



All times are GMT +1. The time now is 09:48 PM.

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