If you work with Microsoft Office Excel often it's good to know how to use the "ActiveCell" property to add, get, and even change the format of data in a Worksheet. Visual Basic for Applications (VBA) is a computer programming language used to automate routine tasks. In VBA you can use the "ActiveCell" property to make changes to your data. With VBA you can save time by automating a process instead of performing the same task manually.
- Skill level:
- Moderately Easy
Other People Are Reading
Launch Microsoft Office Excel, click the "Developer" tab, and click "Visual Basic."
Click the "Insert" menu and click "Module" to insert a new code module. Type the following code to start a new sub procedure:
Private Sub usingActiveCell()
Copy and paste the following to activate "Sheet1:"
Copy and paste the following to add a value to "A1," "A2," and "A3:"
ActiveCell.Value = 3.5
ActiveCell.Value = 10
ActiveCell.Value = 20
Copy and paste the following to highlight the cells with data:
Range(Cells(.Row, .CurrentRegion.Column), Cells(.Row, .CurrentRegion.Columns.Count + .CurrentRegion.Column - 1)).Interior.ColorIndex = 8 Range(Cells(.CurrentRegion.Row, .Column), Cells(.CurrentRegion.Rows.Count + .CurrentRegion.Row - 1, .Column)).Interior.ColorIndex = 8
Application.ScreenUpdating = True
Copy and paste the following to display the values added through the "Immediate Window:"
Copy and paste the following to end the sub procedure:
Press "Ctrl" and "G" to display the "Immediate Window" and press "F5" to run the procedure.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for