Search TeachExcel.com
TeachExcel.com
TE
Teach Excel MS Office Tutorials Excel Consulting Services Excel Forum
Excel Video Tutorials Excel Tips Free Excel Macros Excel Help Resources Contact TeachExcel
Video Tutorials
  • Free Macros
  • Excel Help Directory
  • Excel 2007 Resources
  • Keyboard Shortcuts
  • Excel Forum
  • Contact/About

Tutorials: Macros



Featured Tutorial
Dynamically Update Drop-Dowm Menus in Excel
Featured Macro
Delete Empty Rows in Excel

How to record a Macro - And what One is

Video | Similar Helpful Excel Resources

Bookmark and Share

This is an introduction to what Macros are and how they can make your life easier in excel. You will learn how to create a macro and see how they can automate tasks in excel. A Macro is really just VBA code which can perform functions in excel, but the common user need never see any complicated VBA code, so don't worry.
   Topics Covered
What Macros are and can do
How to Record a Macro
How to create a simple Macro
   Difficulty:         Easy
   Video:               Yes



Got a Question? Ask it Here in the Forum.



Similar Helpful Excel Resources

Previous Record And Next Record Macro Code Needed??? - Excel

View Content
I recently followed the following tutorial listed below to create a "userform":

http://www.contextures.com/xluserform01.html

I need a simple macro to add a "previous" and "next" button(s) in the userform that I have created. The data is currently input into the userform interface, and copied and/or transferred to another sheet in my workbook. I want the ability to view and/or make corrections to the record via userform interface only, without having to navigate to the sheet where the data is located, in order to view and/or make corrections. Any help regarding this matter is appreciated. Awaiting excel super-geeks to assist. Thanks.

Macro Add New Record Without Replacing Or Affecting Old Record - Excel

View Content
Dear Admin,

I got one new idea on my tedious task but I can't figure out how to do that, I really hope that you all can give me some suggestions. Thanks

I got one excel template:-

WorkSheet(Template):
A1 B1
1 Student Exam Paper Preparation
2 Student Name list
3 Student Name tag design
4 Mother's day event

WorkSheet(Data Entry1):
A1 B1
1 Student Exam Paper Preparation
2 Student Name list
3 Student Name tag design
4 Mother's day event

I use to key in the new project in Worksheet(Template) like I might add one more 5 Father's day event. On and Off I got new project add in.
So my teachers will key in their time spend according to the template given in the (Data Entry) worksheet.

In order to make this 2/more worksheets tally, I will use copy paste function(record macro). BUT, once they sort the sequence of the template in their Data Entry worksheets.
I hardly to use macro blindly copy paste.

QUestion:

1. How can I use macro to help me, whenever I got add 3/ more new projects. The macro smart enough to compare with those existing worksheet, just add those NEW projects into their template at bottom, so that wont affect their existing sorting.


Please advice, the example given is under few worksheets in ONE workbook. Actually we work on different workBOOK, so very hard to use copy paste already. Please help Thanks

Macro To Print Record # To Record# - Excel

View Content
Hi,

I'm trying to find a macro that will run allowing the user to select a 'starting record number' and a 'finishing record number' when printing.

I have a spreadsheet that feeds from a master list in excel, from over 5000 records.

I need to print the s'sheet with any given indivdual record's information at any given time.

Individual prints are fine. However if I wanted to print from record number 1500 to record number 3000 it would take me all day.

Is there a way I can set up a macro so an option form pops up? allowing selection of "From record" and "to Record" ?

Thanks in advance.
Naomi

Recall Specific Record To Edit In Userform And Print Multipage Record - Excel

View Content
Hi all! I am new to VBA - very new (as in a week or so). I have written a userform (RSForm) that is working perfectly after many tweaks I have found online. I cannot, however, find a workable solution to the following problems:

1. I need to be able to recall the userform for a specified record with all appropriately supplied data from that record
2. Be able to add/edit information from that record (data entered into rows B2-CZ2)
3. Print the recalled userform for a specified record

So, here's what I am trying to do...with NO success (please help!)

I am trying to add a button to the main worksheet ("Index Number") of my workbook (HPCICatalog) that would open a form that simply requests the input of the index number of the record I am trying to recall (done and working). I have created the userform which includes a textbox for the index number, an OK and Cancel button (super simple). Upon clicking OK, I would like the userform (RSForm) to open up BUT be repopulated with the recorded data for that requested index number rather than just be empty (meaning open the userform with that record's information versus ready/clear for a new record). [I was once able to get it to reopen but it was always blank regardless of the multiple attempts at codes that I have tried thanks to the help of friends who have self-declared themselves VBA experts. The book I bought doesn't help either!]

I would like to be able to edit information on this repopulated userform and have it either just substitute changed info or write-over the originally saved data when I click "Save Changes" (a button already on the form that currently has no attached code because I am clueless).

Finally, I have a "Print" button on my userform. The code for the button is a simple .PrintForm that works except it just prints the first page of the multipage form (but cuts off the right 1/8th because the form is too wide for portrait printing).

I've read a ton of posts. FYI, The index number is a number automatically assigned to column B starting with cell 2. The information that populates the userform runs from B2 through CZ2 and I currently have 85 records. I have attempted to create code to repopulate the userform with the requested index number - none of which remotely worked. They did give me a lovely array of messages from compile to object required errors.

PLEASE help! I would be eternally grateful!

Sincere (very sincere) thanks!!!!!

Beth

Design Query To Select Child Record With No Parent Record From 1 Field - Excel

View Content
I have an Access Database of about 70,000 asset records.The records are a combination of parent and sub assets in a field called AssetTrim. Each asset record is not labeled as parent or subasset but one can identify the subassets based on the length of the string of characters. For Example,
Table Name is 01EN. Field Name is AssetTrim.
AssetTrim
A9211
A921101
A921102
A921103
A921104
A921105
A921106
V6317
KK7335
G533501
Z8432
DA863101
DA869602
DA869603
DA869604
XA3452
XA345201
XA345202
BD175634
BD17563401
BD63984109
In the Table above,
A9211 is a parent asset with 6 subassets(A921101, A921102, A921103, A921104, A921105, A921106). XA3452 and BD175634 are also parent assets with sub assets.
V6317, KK7335 and Z8432 are parent assets with no subasset.
G533501, DA863101 through DA863104 and BD63984109 are subassets with no parent assets.
I am trying to design a query that will select from the AssetTrim field all subassets without a parent. So applying it to the table above, the query's output will be:
G533501
DA863101
DA869602
DA869603
DA869604
BD63984109

Goto A Record Based On Selected Record In Subform Datasheet - Excel

View Content
OK, the title prety much explains things, but for clarity:

I have a form ("Master Form") and a subform ("Basic Skills subform") displaying as a data sheet. The Master form is bound to a dynamic select query created by a set of filters in a separate switchboard style form. The subform is bound to the main data table with no filtration.

The purpose of the subform is to provide a "full view" of the primary data, and I would like to add the functionality to make the "Master Form" goto the record that is selected in the subform datasheet. This is less redundant than it sounds as there is other data from separate tables that is represented in the master form but not in the subform. Plus for data entry, it make things easier to have the data laid out in a form rather than a data sheet.

In my best attempt at making this work (best but not successful), I added the following to the ******* event in a textfield in the subform:

Code:

 
Private Sub CRN_Click()
With Me.Parent.RecordsetClone
    .FindFirst "CRN = " & Me.CRN
    Me.Parent.Bookmark = .Bookmark
End With
End Sub



Any bright people out there who could help make this work?

Auto-populate Several Fields From Previous Record To New Record On A Form - Excel

View Content
Hi!

I have a form which I am using to set up meeting records for clients. I have a command button on that form to open the Reminders form, where I add reminder information for that meeting.

On the meetings form, I have the meeting ID, the client's name(combo box using PK field from the clients table displaying the client's name), their assigned employee, date of meeting, among otheres.

On the reminders form, I also capture the meeting ID, the client's name, date of meeting, among others.

I have the following code attached to the Add Reminders command button:

Code:

    Dim stDocName As String
    stDocName = "frmReminders"
    
    DoCmd.GoToControl "txtCompanyName"
    DoCmd.RunCommand acCmdCopy
    DoCmd.OpenForm stDocName, acNormal, , , acFormAdd
    DoCmd.GoToControl "txtCompanyName"
    DoCmd.RunCommand acCmdPaste
    Forms!frmReminders!txtReminderDate.SetFocus


I tried repeating the copy and paste lines for the other fields but it is not working.

So essentially, when I click the Add Reminders button, I want to copy the company name, visit ID and the visit date to the new record.

Can anyone assist me in achieving this?

Thanks for any help.

Trouble With Macro - Unable To Record Macro - Excel

View Content
Hey guys,

I am having trouble with my excel macro. I have a cell with a long formula and when I try to select A1:A1000 put the formula in and hold control and enter so all the cells pick up the formula, I get the message "unable to record macro". I am using Excel 2002 at work. The formula is:

=IF(AR2=TRUE,(""&T2&";"&U2&";"&V2&";"&W2&";"&X2&";"&Y2&";"&Z2&";"&AA2&";"&AB2&";"&AC2&";"&AD2&";"&AE2&";"&AF2&";"&AG2&";"&AH2&";"&AI2&";"&AJ2&";"&AK2&";"&AL2&";"&AM2&";"&AN2&";"&AO2&";"&AP2&";"&AQ2),(""&S2&";"&T2&";"&U2&";"&V2&";"&W2&";"&X2&";"&Y2&";"&Z2&";"&AA2&";"&AB2&";"&AC2&";"&AD2&";"&AE2&";"&AF2&";"&AG2&";"&AH2&";"&AI2&";"&AJ2&";"&AK2&";"&AL2&";"&AM2&";"&AN2&";"&AO2&";"&AP2&";"&AQ2))

Basically if the cell value is true, pick up all the cells to the right of it and if the cell value is false, pick up all the cells to the right plus one to the left.

Would I need to do this in R1C1 style?



Is It Possible To Automatic Keep A Record In A Column Of Date A Record Was Created? - Excel

View Content
Hi,

How can I automatically have a date created everytime I enter a new line in a spreadsheet.

EG

Name Age Date Entered

Matt 17 17 Jan 11

It would be good to have the Date entered populate (and remain) automatically

Thanks

Populating Fields In New Record Based On Current Record. - Excel

View Content
I have a form with the following details.

Form Name: Frm_Projects
Source Table: Dta_Project_Extract

And the main fields within the table a

Project_ID
Project_Name
Activty_ID
Activity_Name

Within Frm_Projects I have a command button that opens a new form.

Form Name: Frm_Project_Commentary_Add
Source Table: Dta_Project_Comments

And the main fields within the table a

Project_ID
Activty_ID
Date
Comments

The user can record comentary within this sub form for reporting purposes.

How can I have the sub form automatically open as a New Record and pre populate the fields Project_ID and Activty_ID based on the value of the record in Frm_Projects?

Contact | Privacy Policy | Disclaimer
Copyright© 2012 TeachExcel.com