Macro for workbook

G

Guest

How can I write a macro for work book not for just a worksheet?

How can I write a macro so when i hit a button, it will refresh data with
provided password.

How can I write a macro so it will fix width at data/text to column.

Thanks
Daniel
 
G

Guest

Q1 - How can I write a macro for work book not for just a worksheet?

A1 - When you write code in the VB code module, You can direct it to a
workbook, worksheet, control, UserForm, WebSheet, different application and
various other things, based on how you write the code. The variety is so
vast that it is impractical to provide sample code unless you can tie it down
a little more on what you want to do.

Q2 - How can I write a macro so when i hit a button, it will refresh data
with
provided password.

A2 - Again, the area of coverage is so vast that code sample is impractical.
Define the requirement to a list, Query Table, etc.

Q3 - How can I write a macro so it will fix width at data/text to column.

A3 - This is a sample of one way to set column width. You can also specify
the size in points. You can also use autofit, with line wrap off, so that
Excel will automatically size the cell according to the data it receives.
Sub colWdth()
With Worksheets(1).Columns("B:G")
.ColumnWidth = .ColumnWidth * 2
End With
MsgBox Columns("B").ColumnWidth
End Sub

You can also learn more about writing code at the site below.

http://www.cpearson.com/excel/vbe.htm
 

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

Top